Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
momo 2023-11-15 17:40:52 +08:00
commit e6b8124a72

View File

@ -42,12 +42,11 @@ type DNItem struct {
func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
//从ldap获取组织架构数据
// 创建搜索请求
searchRequest := ldap.NewSearchRequest(
l.svcCtx.Config.Ldap.BaseDN,
l.svcCtx.Config.Ldap.BaseDN, //这里后续需要修改,不同的人只能查询他的下属列表
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
"(objectClass=*)", //所有object
[]string{ /*"cn", "sn", "givenName", "mail", "telephoneNumber", "department", "title"*/ },
nil,
nil,
)
// 执行搜索请求
@ -61,13 +60,14 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.
sortNum++
attribute := make(map[string]interface{})
for _, attr := range v.Attributes {
//objectcalss属性特别处理
if attr.Name == "objectClass" {
mapObjectClass := make(map[string]struct{})
for _, objectClassItem := range attr.Values {
mapObjectClass[objectClassItem] = struct{}{}
}
attribute[attr.Name] = mapObjectClass
} else {
} else { //普通属性
attribute[attr.Name] = strings.Join(attr.Values, ",")
}
}