From 4deebe2a64351e43fc13bafaab5a9877e87c92de Mon Sep 17 00:00:00 2001
From: Sohalt <sohalt@sohalt.net>
Date: Wed, 15 Apr 2020 14:26:23 +0200
Subject: [PATCH] [BUGFIX] Allow username_attribute == mail_attribute (#865)

---
 internal/authentication/ldap_user_provider.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/internal/authentication/ldap_user_provider.go b/internal/authentication/ldap_user_provider.go
index a9a26760..97fd6f41 100644
--- a/internal/authentication/ldap_user_provider.go
+++ b/internal/authentication/ldap_user_provider.go
@@ -162,7 +162,8 @@ func (p *LDAPUserProvider) getUserProfile(conn LDAPConnection, inputUsername str
 	for _, attr := range sr.Entries[0].Attributes {
 		if attr.Name == p.configuration.MailAttribute {
 			userProfile.Emails = attr.Values
-		} else if attr.Name == p.configuration.UsernameAttribute {
+		}
+		if attr.Name == p.configuration.UsernameAttribute {
 			if len(attr.Values) != 1 {
 				return nil, fmt.Errorf("User %s cannot have multiple value for attribute %s",
 					inputUsername, p.configuration.UsernameAttribute)