mirror of
https://github.com/goharbor/harbor
synced 2025-04-26 21:31:42 +00: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 {
|
for _, groupEntry := range result.Entries {
|
||||||
nestedGroupDNList = append(nestedGroupDNList, strings.TrimSpace(groupEntry.DN))
|
if !contains(u.GroupDNList, groupEntry.DN) {
|
||||||
log.Debugf("Found group %v", 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...)
|
u.GroupDNList = append(u.GroupDNList, nestedGroupDNList...)
|
||||||
log.Debugf("Done searching for nested groups")
|
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 + "))"
|
filter = "(&(objectClass=group)(member:1.2.840.113556.1.4.1941:=" + userDN + "))"
|
||||||
return filter
|
return filter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func contains(s []string, e string) bool {
|
||||||
|
for _, a := range s {
|
||||||
|
if a == e {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user