This commit is contained in:
laodaming 2023-11-22 13:07:05 +08:00
parent 67ac4b37a2
commit e5a73420b6

View File

@ -60,27 +60,32 @@ func (l *GetLdapOrganizationMembersLogic) GetLdapOrganizationMembers(req *types.
filterBuilder := strings.Builder{}
memberCount := 0
memberDNList := make([]string, 0, 100)
for _, entry := range result.Entries {
if entry.DN != req.OrganizationDN {
if len(result.Entries) == 0 {
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLdapOrganizationMembersRsp{
List: []types.GetLdapOrganizationMembersItem{},
})
}
teamGroup := result.Entries[0]
if teamGroup.DN != req.OrganizationDN {
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetLdapOrganizationMembersRsp{
List: []types.GetLdapOrganizationMembersItem{},
})
}
//查到用户信息了
for _, attr := range teamGroup.Attributes {
if attr.Name != "uniqueMember" {
continue
}
//查到用户信息了
for _, attr := range entry.Attributes {
if attr.Name != "uniqueMember" {
memberCount = len(attr.Values)
memberDNList = attr.Values
for _, memberDn := range attr.Values {
//不需要根用户
if memberDn == l.svcCtx.Config.Ldap.RootDN {
continue
}
memberCount = len(attr.Values)
memberDNList = attr.Values
for _, memberDn := range attr.Values {
//不需要根用户
if memberDn == l.svcCtx.Config.Ldap.RootDN {
continue
}
//解析dn成每个小的单元
cellList := strings.Split(memberDn, ",") //取cn邮箱
filterBuilder.WriteString(fmt.Sprintf("(%s)", cellList[0]))
}
break
//解析dn成每个小的单元
cellList := strings.Split(memberDn, ",") //取cn邮箱
filterBuilder.WriteString(fmt.Sprintf("(%s)", cellList[0]))
}
break
}