mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 20:26:13 +01:00
Merge pull request #2097 from reasonerjt/fix-ldap-1.1.0
fix issue in LDAP support
This commit is contained in:
commit
3038790faa
@ -31,8 +31,6 @@ import (
|
|||||||
goldap "gopkg.in/ldap.v2"
|
goldap "gopkg.in/ldap.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
var attributes = []string{"uid", "cn", "mail", "email"}
|
|
||||||
|
|
||||||
// GetSystemLdapConf ...
|
// GetSystemLdapConf ...
|
||||||
func GetSystemLdapConf() (models.LdapConf, error) {
|
func GetSystemLdapConf() (models.LdapConf, error) {
|
||||||
var err error
|
var err error
|
||||||
@ -205,8 +203,9 @@ func SearchUser(ldapConfs models.LdapConf) ([]models.LdapUser, error) {
|
|||||||
var u models.LdapUser
|
var u models.LdapUser
|
||||||
for _, attr := range ldapEntry.Attributes {
|
for _, attr := range ldapEntry.Attributes {
|
||||||
val := attr.Values[0]
|
val := attr.Values[0]
|
||||||
switch attr.Name {
|
log.Debugf("Current ldap entry attr name: %s\n", attr.Name)
|
||||||
case ldapConfs.LdapUID:
|
switch strings.ToLower(attr.Name) {
|
||||||
|
case strings.ToLower(ldapConfs.LdapUID):
|
||||||
u.Username = val
|
u.Username = val
|
||||||
case "uid":
|
case "uid":
|
||||||
u.Realname = val
|
u.Realname = val
|
||||||
@ -358,6 +357,11 @@ func searchLDAP(ldapConfs models.LdapConf, ldap *goldap.Conn) (*goldap.SearchRes
|
|||||||
ldapScope := ldapConfs.LdapScope
|
ldapScope := ldapConfs.LdapScope
|
||||||
ldapFilter := ldapConfs.LdapFilter
|
ldapFilter := ldapConfs.LdapFilter
|
||||||
|
|
||||||
|
attributes := []string{"uid", "cn", "mail", "email"}
|
||||||
|
lowerUID := strings.ToLower(ldapConfs.LdapUID)
|
||||||
|
if lowerUID != "uid" && lowerUID != "cn" && lowerUID != "mail" && lowerUID != "email" {
|
||||||
|
attributes = append(attributes, ldapConfs.LdapUID)
|
||||||
|
}
|
||||||
searchRequest := goldap.NewSearchRequest(
|
searchRequest := goldap.NewSearchRequest(
|
||||||
ldapBaseDn,
|
ldapBaseDn,
|
||||||
ldapScope,
|
ldapScope,
|
||||||
|
Loading…
Reference in New Issue
Block a user