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 {
|
||||
Attribute map[string]interface{} `json:"attribute"`
|
||||
HasMember bool `json:"has_member"` //是否有成员
|
||||
DN string `json:"dn"`
|
||||
ParentDN string `json:"parent_dn"`
|
||||
Sort int `json:"sort"`
|
||||
|
@ -53,7 +54,7 @@ func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, use
|
|||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "基础用户组的DN未配置")
|
||||
}
|
||||
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)
|
||||
if err != nil {
|
||||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "查询失败:"+err.Error())
|
||||
|
@ -64,12 +65,19 @@ func (l *GetLdapOrganizationsLogic) GetLdapOrganizations(req *types.Request, use
|
|||
for _, v := range searchResult.Entries {
|
||||
sortNum++
|
||||
attribute := make(map[string]interface{})
|
||||
hasMember := false
|
||||
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, ",")
|
||||
}
|
||||
mapDN[v.DN] = &DNItem{
|
||||
DN: v.DN,
|
||||
ParentDN: "",
|
||||
HasMember: hasMember,
|
||||
Attribute: attribute,
|
||||
Sort: sortNum,
|
||||
Child: make([]*DNItem, 0, 100),
|
||||
|
|
Loading…
Reference in New Issue
Block a user