diff --git a/ldap.py b/ldap.py
index dae4a3f1a5e19d3b6ab2431c70781fb97dd573be..47a079ee877798942a8564120f3607976eff64f5 100644
--- a/ldap.py
+++ b/ldap.py
@@ -7,7 +7,8 @@ if 'LDAP_HOST' in config:
 	import ldap3
 
 	def ldapauth(user, password): # pylint: disable=function-redefined
-		user = LDAP_USERRE.sub(r'', user.lower())
+		if LDAP_USERRE.search(user):
+			return {}, []
 		try:
 			server = ldap3.Server(config['LDAP_HOST'], port=config['LDAP_PORT'], use_ssl=True)
 			conn = ldap3.Connection(server, 'fsmpi\\%s'%user, password, auto_bind=True, check_names=False)
@@ -26,7 +27,8 @@ else:
 	}
 
 	def ldapauth(user, password): # pylint: disable=function-redefined
-		user = LDAP_USERRE.sub(r'', user.lower())
+		if LDAP_USERRE.search(user):
+			return {}, []
 		if config.get('DEBUG') and user in NOTLDAP and password == NOTLDAP[user][0]:
 			return NOTLDAP[user][2], NOTLDAP[user][1]
 		return {}, []