nebius/SWE-bench-extra huggingface dataset:
Repository: matrix-org/matrix-synapse-ldap3

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 

Comments:

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 @@ class LdapAuthProvider:
             except ActiveDirectoryUPNException:
                 return None
 
+        localpart = localpart.lower()
+
         try:
             server = self._get_server()
             logger.debug("Attempting LDAP connection with %s", self.ldap_uris)
diff --git a/setup.cfg b/setup.cfg
index 92c3c4c..8b0779c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,7 +31,7 @@ dev =
   types-setuptools
 
   # for linting
-  black == 21.9b0
+  black == 22.3.0
   flake8 == 4.0.1
   isort == 5.9.3
 


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 @@ class LdapSimpleTestCase(unittest.TestCase):
         )
         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