mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
commit
365145d2cd
1 changed files with 0 additions and 29 deletions
|
@ -216,32 +216,3 @@ func (lc *LDAPClient) Authenticate(username, password string) (bool, map[string]
|
|||
|
||||
return true, user, nil
|
||||
}
|
||||
|
||||
// GetGroupsOfUser returns the group for a user.
|
||||
func (lc *LDAPClient) GetGroupsOfUser(username string) ([]string, error) {
|
||||
err := lc.Connect()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
searchRequest := ldap.NewSearchRequest(
|
||||
lc.Base,
|
||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||
fmt.Sprintf(lc.GroupFilter, username),
|
||||
[]string{"cn"}, // can it be something else than "cn"?
|
||||
nil,
|
||||
)
|
||||
sr, err := lc.Conn.Search(searchRequest)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
groups := []string{}
|
||||
|
||||
for _, entry := range sr.Entries {
|
||||
groups = append(groups, entry.GetAttributeValue("cn"))
|
||||
}
|
||||
|
||||
return groups, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue