mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 20:27:50 +01:00
#1554 check adminFilter length before LDAP search
This commit is contained in:
parent
90a6553c37
commit
f1adbca0f1
@ -120,13 +120,14 @@ func (ls Ldapsource) SearchEntry(name, passwd string) (string, string, string, b
|
|||||||
sn_attr := sr.Entries[0].GetAttributeValue(ls.AttributeSurname)
|
sn_attr := sr.Entries[0].GetAttributeValue(ls.AttributeSurname)
|
||||||
mail_attr := sr.Entries[0].GetAttributeValue(ls.AttributeMail)
|
mail_attr := sr.Entries[0].GetAttributeValue(ls.AttributeMail)
|
||||||
|
|
||||||
|
admin_attr := false
|
||||||
|
if len(ls.AdminFilter) > 0 {
|
||||||
search = ldap.NewSearchRequest(
|
search = ldap.NewSearchRequest(
|
||||||
userDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, ls.AdminFilter,
|
userDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, ls.AdminFilter,
|
||||||
[]string{ls.AttributeName},
|
[]string{ls.AttributeName},
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
sr, err = l.Search(search)
|
sr, err = l.Search(search)
|
||||||
admin_attr := false
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(4, "LDAP Admin Search failed unexpectedly! (%v)", err)
|
log.Error(4, "LDAP Admin Search failed unexpectedly! (%v)", err)
|
||||||
} else if len(sr.Entries) < 1 {
|
} else if len(sr.Entries) < 1 {
|
||||||
@ -134,6 +135,7 @@ func (ls Ldapsource) SearchEntry(name, passwd string) (string, string, string, b
|
|||||||
} else {
|
} else {
|
||||||
admin_attr = true
|
admin_attr = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return name_attr, sn_attr, mail_attr, admin_attr, true
|
return name_attr, sn_attr, mail_attr, admin_attr, true
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user