fix
This commit is contained in:
parent
84f8323832
commit
6822c3d94c
|
@ -15,6 +15,6 @@ type Config struct {
|
|||
Host string
|
||||
BindDN string
|
||||
Password string
|
||||
RootDN string
|
||||
BaseDN string
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
//组织层级关系
|
||||
|
|
Loading…
Reference in New Issue
Block a user