mirror of
https://github.com/grafana/grafana.git
synced 2025-01-23 23:13:52 -06:00
handle "dn" ldap attribute more gracefully (#12385)
* handle "dn" ldap attribute more gracefully * use strings.ToLower
This commit is contained in:
parent
dd7a653db9
commit
583df47c2f
@ -308,9 +308,6 @@ func (a *ldapAuther) searchForUser(username string) (*LdapUserInfo, error) {
|
|||||||
} else {
|
} else {
|
||||||
filter_replace = getLdapAttr(a.server.GroupSearchFilterUserAttribute, searchResult)
|
filter_replace = getLdapAttr(a.server.GroupSearchFilterUserAttribute, searchResult)
|
||||||
}
|
}
|
||||||
if a.server.GroupSearchFilterUserAttribute == "dn" {
|
|
||||||
filter_replace = searchResult.Entries[0].DN
|
|
||||||
}
|
|
||||||
|
|
||||||
filter := strings.Replace(a.server.GroupSearchFilter, "%s", ldap.EscapeFilter(filter_replace), -1)
|
filter := strings.Replace(a.server.GroupSearchFilter, "%s", ldap.EscapeFilter(filter_replace), -1)
|
||||||
|
|
||||||
@ -334,11 +331,7 @@ func (a *ldapAuther) searchForUser(username string) (*LdapUserInfo, error) {
|
|||||||
|
|
||||||
if len(groupSearchResult.Entries) > 0 {
|
if len(groupSearchResult.Entries) > 0 {
|
||||||
for i := range groupSearchResult.Entries {
|
for i := range groupSearchResult.Entries {
|
||||||
if a.server.Attr.MemberOf == "dn" {
|
memberOf = append(memberOf, getLdapAttrN(a.server.Attr.MemberOf, groupSearchResult, i))
|
||||||
memberOf = append(memberOf, groupSearchResult.Entries[i].DN)
|
|
||||||
} else {
|
|
||||||
memberOf = append(memberOf, getLdapAttrN(a.server.Attr.MemberOf, groupSearchResult, i))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -356,7 +349,7 @@ func (a *ldapAuther) searchForUser(username string) (*LdapUserInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getLdapAttrN(name string, result *ldap.SearchResult, n int) string {
|
func getLdapAttrN(name string, result *ldap.SearchResult, n int) string {
|
||||||
if name == "DN" {
|
if strings.ToLower(name) == "dn" {
|
||||||
return result.Entries[n].DN
|
return result.Entries[n].DN
|
||||||
}
|
}
|
||||||
for _, attr := range result.Entries[n].Attributes {
|
for _, attr := range result.Entries[n].Attributes {
|
||||||
|
Loading…
Reference in New Issue
Block a user