mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-19 16:55:16 +01:00
Prevent duplicated entries
Signed-off-by: Yann David <davidyann88@gmail.com>
This commit is contained in:
parent
51eb8bc60f
commit
6435f32bc5
@ -230,9 +230,14 @@ func (session *Session) SearchUser(username string) ([]models.LdapUser, error) {
|
||||
}
|
||||
|
||||
for _, groupEntry := range result.Entries {
|
||||
if !contains(u.GroupDNList, groupEntry.DN) {
|
||||
nestedGroupDNList = append(nestedGroupDNList, strings.TrimSpace(groupEntry.DN))
|
||||
log.Debugf("Found group %v", groupEntry.DN)
|
||||
} else {
|
||||
log.Debugf("%v is already in GroupDNList", groupEntry.DN)
|
||||
}
|
||||
}
|
||||
|
||||
u.GroupDNList = append(u.GroupDNList, nestedGroupDNList...)
|
||||
log.Debugf("Done searching for nested groups")
|
||||
|
||||
@ -441,3 +446,12 @@ func createNestedGroupFilter(userDN string) string {
|
||||
filter = "(&(objectClass=group)(member:1.2.840.113556.1.4.1941:=" + userDN + "))"
|
||||
return filter
|
||||
}
|
||||
|
||||
func contains(s []string, e string) bool {
|
||||
for _, a := range s {
|
||||
if a == e {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user