diff --git a/server/ldap-admin/internal/config/config.go b/server/ldap-admin/internal/config/config.go index b802edcd..4c76a6a2 100644 --- a/server/ldap-admin/internal/config/config.go +++ b/server/ldap-admin/internal/config/config.go @@ -15,6 +15,6 @@ type Config struct { Host string BindDN string Password string - RootDN string + BaseDN string } } diff --git a/server/ldap-admin/internal/logic/getdepartmentslogic.go b/server/ldap-admin/internal/logic/getdepartmentslogic.go index 2218b960..ce311be6 100644 --- a/server/ldap-admin/internal/logic/getdepartmentslogic.go +++ b/server/ldap-admin/internal/logic/getdepartmentslogic.go @@ -32,19 +32,18 @@ func NewGetDepartmentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge // 处理进入前逻辑w,r // func (l *GetDepartmentsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) { // } -type mapDnItem struct { +type DNItem struct { Attribute map[string]interface{} `json:"attribute"` DN string `json:"dn"` Sort int `json:"sort"` - Child []*mapDnItem `json:"child"` + Child []*DNItem `json:"child"` } func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) { //从ldap获取组织架构数据 - searchBase := "dc=fusen,dc=com" // 创建搜索请求 searchRequest := ldap.NewSearchRequest( - searchBase, + l.svcCtx.Config.Ldap.BaseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, "(objectClass=*)", []string{ /*"cn", "sn", "givenName", "mail", "telephoneNumber", "department", "title"*/ }, @@ -55,7 +54,7 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth. if err != nil { log.Fatal(err) } - mapDN := make(map[string]*mapDnItem) + mapDN := make(map[string]*DNItem) sortNum := 0 for _, v := range searchResult.Entries { sortNum++ @@ -71,11 +70,11 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth. attribute[attr.Name] = strings.Join(attr.Values, ",") } } - mapDN[v.DN] = &mapDnItem{ + mapDN[v.DN] = &DNItem{ DN: v.DN, Attribute: attribute, Sort: sortNum, - Child: make([]*mapDnItem, 0, 100), + Child: make([]*DNItem, 0, 100), } } //组织层级关系