Repository: matrix-org/matrix-synapse-ldap3 (language: python)

Issue:
Can login only with lowercase username
Hello,

it looks like that, when the user tries to login with uppercase or a combination of uppercase and lowercase, the login fails. 
The only way to login using the Active Directory credentials is to use only lowercase. 

In the configuration we have:
     attributes:
        uid: "sAMAccountName"
        mail: "mail"
        name: "displayName"

Is there a way to allow the users to login without caring about the case sensitivity? 

Thank you in advance 


Discussion / hints:
Any idea where this issue is coming from? if someone can point me in the right direction, I can maybe try to fix this, as it has been irritating me as well.
I don't think Synapse is able to handle uppercase names at all. The best way to fix it would be to have the matrix-synapse-ldap3 plugin translate things into lowercase for everything.
> 
> 
> I don't think Synapse is able to handle uppercase names at all. The best way to fix it would be to have the matrix-synapse-ldap3 plugin translate things into lowercase for everything.

I'm just running into the same problem. 
I want to use ldap. my usernames are already tied because of another service we're using. Sure, I can tell them not tu use uppercase for usernames at Synapse, but for sure this will confuse some of them to use their user name without uppercase here, but with uppercase there. 


Fix patch:
diff --git a/ldap_auth_provider.py b/ldap_auth_provider.py
index 9398350..dcefe15 100644
--- a/ldap_auth_provider.py
+++ b/ldap_auth_provider.py
@@ -133,6 +133,8 @@ async def check_auth(
             except ActiveDirectoryUPNException:
                 return None
 
+        localpart = localpart.lower()
+
         try:
             server = self._get_server()
             logger.debug("Attempting LDAP connection with %s", self.ldap_uris)


Test patch:
diff --git a/tests/test_simple.py b/tests/test_simple.py
index 0ffaf7f..6e570b0 100644
--- a/tests/test_simple.py
+++ b/tests/test_simple.py
@@ -95,6 +95,15 @@ def test_no_pwd(self):
         )
         self.assertFalse(result)
 
+    @defer.inlineCallbacks
+    def test_uppercase_username(self):
+        result = yield defer.ensureDeferred(
+            self.auth_provider.check_auth(
+                "BOB", "m.login.password", {"password": "secret"}
+            )
+        )
+        self.assertEqual(result, "@bob:test")
+
 
 class LdapSearchTestCase(unittest.TestCase):
     @defer.inlineCallbacks