|
|
@@ -84,11 +84,25 @@ func (h ldapHandler) Search(boundDN string, searchReq ldap.SearchRequest, conn n
|
|
|
fmt.Printf("%s,search......%s\n", boundDN, searchReq)
|
|
|
userName := ""
|
|
|
if boundDN == "cn=qianqiuiot" {
|
|
|
- start := strings.Index(searchReq.Filter, "uid=")
|
|
|
- end := strings.Index(searchReq.Filter[start:], ")")
|
|
|
- fmt.Println("%d,%d", start, end)
|
|
|
- userName = searchReq.Filter[start+4 : start+end]
|
|
|
- fmt.Println(userName)
|
|
|
+ if searchReq.Filter == "(objectClass=*)" {
|
|
|
+ uid := searchReq.BaseDN
|
|
|
+ dn := uid
|
|
|
+ if dn == "" {
|
|
|
+ dn = boundDN
|
|
|
+ }
|
|
|
+ entries := []*ldap.Entry{
|
|
|
+ &ldap.Entry{dn, []*ldap.EntryAttribute{
|
|
|
+ //&ldap.EntryAttribute{"uid", []string{}},
|
|
|
+ }},
|
|
|
+ }
|
|
|
+ return ldap.ServerSearchResult{entries, []string{}, []ldap.Control{}, ldap.LDAPResultSuccess}, nil
|
|
|
+ }else {
|
|
|
+ start := strings.Index(searchReq.Filter, "uid=")
|
|
|
+ end := strings.Index(searchReq.Filter[start:], ")")
|
|
|
+ fmt.Println("%d,%d", start, end)
|
|
|
+ userName = searchReq.Filter[start+4 : start+end]
|
|
|
+ fmt.Println(userName)
|
|
|
+ }
|
|
|
}else {
|
|
|
userName = boundDN[3:]
|
|
|
}
|