fix
This commit is contained in:
parent
84f8323832
commit
6822c3d94c
|
@ -15,6 +15,6 @@ type Config struct {
|
||||||
Host string
|
Host string
|
||||||
BindDN string
|
BindDN string
|
||||||
Password string
|
Password string
|
||||||
RootDN string
|
BaseDN string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,19 +32,18 @@ func NewGetDepartmentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ge
|
||||||
// 处理进入前逻辑w,r
|
// 处理进入前逻辑w,r
|
||||||
// func (l *GetDepartmentsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
// func (l *GetDepartmentsLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||||||
// }
|
// }
|
||||||
type mapDnItem struct {
|
type DNItem struct {
|
||||||
Attribute map[string]interface{} `json:"attribute"`
|
Attribute map[string]interface{} `json:"attribute"`
|
||||||
DN string `json:"dn"`
|
DN string `json:"dn"`
|
||||||
Sort int `json:"sort"`
|
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) {
|
func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||||
//从ldap获取组织架构数据
|
//从ldap获取组织架构数据
|
||||||
searchBase := "dc=fusen,dc=com"
|
|
||||||
// 创建搜索请求
|
// 创建搜索请求
|
||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
searchBase,
|
l.svcCtx.Config.Ldap.BaseDN,
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
"(objectClass=*)",
|
"(objectClass=*)",
|
||||||
[]string{ /*"cn", "sn", "givenName", "mail", "telephoneNumber", "department", "title"*/ },
|
[]string{ /*"cn", "sn", "givenName", "mail", "telephoneNumber", "department", "title"*/ },
|
||||||
|
@ -55,7 +54,7 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
mapDN := make(map[string]*mapDnItem)
|
mapDN := make(map[string]*DNItem)
|
||||||
sortNum := 0
|
sortNum := 0
|
||||||
for _, v := range searchResult.Entries {
|
for _, v := range searchResult.Entries {
|
||||||
sortNum++
|
sortNum++
|
||||||
|
@ -71,11 +70,11 @@ func (l *GetDepartmentsLogic) GetDepartments(req *types.Request, userinfo *auth.
|
||||||
attribute[attr.Name] = strings.Join(attr.Values, ",")
|
attribute[attr.Name] = strings.Join(attr.Values, ",")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mapDN[v.DN] = &mapDnItem{
|
mapDN[v.DN] = &DNItem{
|
||||||
DN: v.DN,
|
DN: v.DN,
|
||||||
Attribute: attribute,
|
Attribute: attribute,
|
||||||
Sort: sortNum,
|
Sort: sortNum,
|
||||||
Child: make([]*mapDnItem, 0, 100),
|
Child: make([]*DNItem, 0, 100),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//组织层级关系
|
//组织层级关系
|
||||||
|
|
Loading…
Reference in New Issue
Block a user