aboutsummaryrefslogtreecommitdiff
path: root/pkg/auth/ldap
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/auth/ldap')
-rw-r--r--pkg/auth/ldap/ldap.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/auth/ldap/ldap.go b/pkg/auth/ldap/ldap.go
index 4e0a4665..63b2bc39 100644
--- a/pkg/auth/ldap/ldap.go
+++ b/pkg/auth/ldap/ldap.go
@@ -96,13 +96,15 @@ func (ls *Source) sanitizedGroupDN(groupDn string) (string, bool) {
func (ls *Source) findUserDN(l *ldap.Conn, name string) (string, bool) {
log.Trace("Search for LDAP user: %s", name)
- if ls.BindDN != "" && ls.BindPassword != "" {
- err := l.Bind(ls.BindDN, ls.BindPassword)
+ if len(ls.BindDN) > 0 && len(ls.BindPassword) > 0 {
+ // Replace placeholders with username
+ bindDN := strings.Replace(ls.BindDN, "%s", name, -1)
+ err := l.Bind(bindDN, ls.BindPassword)
if err != nil {
- log.Trace("LDAP: Failed to bind as BindDN '%s': %v", ls.BindDN, err)
+ log.Trace("LDAP: Failed to bind as BindDN '%s': %v", bindDN, err)
return "", false
}
- log.Trace("LDAP: Bound as BindDN: %s", ls.BindDN)
+ log.Trace("LDAP: Bound as BindDN: %s", bindDN)
} else {
log.Trace("LDAP: Proceeding with anonymous LDAP search")
}