diff options
author | zeripath <art27@cantab.net> | 2021-09-15 10:28:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 10:28:37 +0100 |
commit | db6b7db06df5feee87c29000c19a52dbf9a150cc (patch) | |
tree | b7ec09fb957b9c4e6911efc3e326462746f8e1ed /services/auth/source/ldap/source_search.go | |
parent | 976db2a8b78b18f6ca934b9da93b4e3b2c746de5 (diff) | |
download | gitea-db6b7db06df5feee87c29000c19a52dbf9a150cc.tar.gz gitea-db6b7db06df5feee87c29000c19a52dbf9a150cc.zip |
Improve LDAP synchronization efficiency (#16994)
The current LDAP sync routine has order n^2 efficiency. This change reduces this
to order n.log n.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services/auth/source/ldap/source_search.go')
-rw-r--r-- | services/auth/source/ldap/source_search.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/services/auth/source/ldap/source_search.go b/services/auth/source/ldap/source_search.go index 71db0b770a..9fe2443768 100644 --- a/services/auth/source/ldap/source_search.go +++ b/services/auth/source/ldap/source_search.go @@ -26,6 +26,7 @@ type SearchResult struct { SSHPublicKey []string // SSH Public Key IsAdmin bool // if user is administrator IsRestricted bool // if user is restricted + LowerName string // Lowername } func (ls *Source) sanitizedUserQuery(username string) (string, bool) { @@ -363,6 +364,7 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul } return &SearchResult{ + LowerName: strings.ToLower(username), Username: username, Name: firstname, Surname: surname, @@ -440,6 +442,8 @@ func (ls *Source) SearchEntries() ([]*SearchResult, error) { if isAttributeSSHPublicKeySet { result[i].SSHPublicKey = v.GetAttributeValues(ls.AttributeSSHPublicKey) } + result[i].LowerName = strings.ToLower(result[i].Username) + } return result, nil |