diff --git a/server/ldap-admin/internal/logic/getdepartmentslogic.go b/server/ldap-admin/internal/logic/getdepartmentslogic.go index 4263de5d..17398ec3 100644 --- a/server/ldap-admin/internal/logic/getdepartmentslogic.go +++ b/server/ldap-admin/internal/logic/getdepartmentslogic.go @@ -33,10 +33,10 @@ func NewGetDepartmentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge // func (l *GetDepartmentsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { // } type mapDnItem struct { - EntryAttribute []*ldap.EntryAttribute `json:"entry_attribute"` - DN string `json:"dn"` - Sort int `json:"sort"` - Child []*mapDnItem `json:"child"` + Attribute map[string]interface{} `json:"attribute"` + DN string `json:"dn"` + Sort int `json:"sort"` + Child []*mapDnItem `json:"child"` } func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { @@ -59,11 +59,23 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth. sortNum := 0 for _, v := range searchResult.Entries { sortNum++ + attribute := make(map[string]interface{}) + for _, attr := range v.Attributes { + if attr.Name == "objectClass" { + mapObjectClass := make(map[string]struct{}) + for _, objectClassItem := range attr.Values { + mapObjectClass[objectClassItem] = struct{}{} + } + attribute[attr.Name] = mapObjectClass + } else { + attribute[attr.Name] = strings.Join(attr.Values, ",") + } + } mapDN[v.DN] = &mapDnItem{ - DN: v.DN, - EntryAttribute: v.Attributes, - Sort: sortNum, - Child: make([]*mapDnItem, 0, 100), + DN: v.DN, + Attribute: attribute, + Sort: sortNum, + Child: make([]*mapDnItem, 0, 100), } } //组织层级关系