fix
This commit is contained in:
parent
6a7b9d295e
commit
18b27b61ac
|
@ -35,6 +35,7 @@ func NewGetLdapOrganizationsLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||||
// }
|
// }
|
||||||
type DNItem struct {
|
type DNItem struct {
|
||||||
Attribute map[string]interface{} `json:"attribute"`
|
Attribute map[string]interface{} `json:"attribute"`
|
||||||
|
HasMember bool `json:"has_member"` //是否有成员
|
||||||
DN string `json:"dn"`
|
DN string `json:"dn"`
|
||||||
ParentDN string `json:"parent_dn"`
|
ParentDN string `json:"parent_dn"`
|
||||||
Sort int `json:"sort"`
|
Sort int `json:"sort"`
|
||||||
|
@ -53,7 +54,7 @@ func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, use
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "基础用户组的DN未配置")
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "基础用户组的DN未配置")
|
||||||
}
|
}
|
||||||
filter := "(|(&(objectClass=groupOfUniqueNames)(objectClass=top))(objectClass=organization))"
|
filter := "(|(&(objectClass=groupOfUniqueNames)(objectClass=top))(objectClass=organization))"
|
||||||
fields := []string{"businessCategory", "dn"}
|
fields := []string{"businessCategory", "dn", "uniqueMember"}
|
||||||
searchResult, err := ldapServer.Search(l.svcCtx.Config.Ldap.BaseDN, ldap.ScopeWholeSubtree, filter, fields, nil)
|
searchResult, err := ldapServer.Search(l.svcCtx.Config.Ldap.BaseDN, ldap.ScopeWholeSubtree, filter, fields, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "查询失败:"+err.Error())
|
return resp.SetStatusWithMessage(basic.CodeServiceErr, "查询失败:"+err.Error())
|
||||||
|
@ -64,12 +65,19 @@ func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, use
|
||||||
for _, v := range searchResult.Entries {
|
for _, v := range searchResult.Entries {
|
||||||
sortNum++
|
sortNum++
|
||||||
attribute := make(map[string]interface{})
|
attribute := make(map[string]interface{})
|
||||||
|
hasMember := false
|
||||||
for _, attr := range v.Attributes {
|
for _, attr := range v.Attributes {
|
||||||
|
//判断是否有成员(不包含root用户所以判断大于1)
|
||||||
|
if attr.Name == "uniqueMember" && len(attr.Values) > 1 {
|
||||||
|
hasMember = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
attribute[attr.Name] = strings.Join(attr.Values, ",")
|
attribute[attr.Name] = strings.Join(attr.Values, ",")
|
||||||
}
|
}
|
||||||
mapDN[v.DN] = &DNItem{
|
mapDN[v.DN] = &DNItem{
|
||||||
DN: v.DN,
|
DN: v.DN,
|
||||||
ParentDN: "",
|
ParentDN: "",
|
||||||
|
HasMember: hasMember,
|
||||||
Attribute: attribute,
|
Attribute: attribute,
|
||||||
Sort: sortNum,
|
Sort: sortNum,
|
||||||
Child: make([]*DNItem, 0, 100),
|
Child: make([]*DNItem, 0, 100),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user