fix
This commit is contained in:
parent
d362c1d496
commit
d4c7aad3ab
|
@ -17,5 +17,6 @@ type Config struct {
|
||||||
Password string
|
Password string
|
||||||
BaseDN string
|
BaseDN string
|
||||||
RootDN string
|
RootDN string
|
||||||
|
PeopleGroupOu string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,14 @@ type DNItem struct {
|
||||||
|
|
||||||
func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
//从ldap获取组织架构数据
|
//从ldap获取组织架构数据
|
||||||
|
rootCn := strings.Split(l.svcCtx.Config.Ldap.RootDN, ",")
|
||||||
|
if len(rootCn) == 0 {
|
||||||
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "root dn is not set")
|
||||||
|
}
|
||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
l.svcCtx.Config.Ldap.BaseDN, //这里后续需要修改,不同的人只能查询他的下属列表
|
l.svcCtx.Config.Ldap.BaseDN, //这里后续需要修改,不同的人只能查询他的下属列表
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
"(objectClass=*)", //所有object
|
"(&(objectClass=*)(!(ou="+l.svcCtx.Config.Ldap.PeopleGroupOu+"))(!("+rootCn[0]+")))", //所有object但是不包括people以及root用户
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
@ -59,9 +63,9 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.
|
||||||
//每个DN存入map
|
//每个DN存入map
|
||||||
for _, v := range searchResult.Entries {
|
for _, v := range searchResult.Entries {
|
||||||
//如果是root用户则跳过
|
//如果是root用户则跳过
|
||||||
if v.DN == l.svcCtx.Config.Ldap.RootDN {
|
/*if v.DN == l.svcCtx.Config.Ldap.RootDN {
|
||||||
continue
|
continue
|
||||||
}
|
}*/
|
||||||
sortNum++
|
sortNum++
|
||||||
attribute := make(map[string]interface{})
|
attribute := make(map[string]interface{})
|
||||||
for _, attr := range v.Attributes {
|
for _, attr := range v.Attributes {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user