fix: LDAP user login exception

This commit is contained in:
xiaoc
2026-05-29 17:59:02 +08:00
committed by wangruidong
parent fb1b8ab819
commit 02137ec789

View File

@@ -186,6 +186,19 @@ class LDAPUser(_LDAPUser):
else:
self._user_dn = self._search_for_user_dn()
def _authenticate_user_dn(self, password):
if self.dn is None:
raise self.AuthenticationFailed("failed to map the username to a DN.")
self._connection = None
self._connection_bound = False
try:
sticky = self.settings.BIND_AS_AUTHENTICATING_USER
self._bind_as(self.dn, password, sticky=sticky)
except ldap.INVALID_CREDENTIALS:
raise self.AuthenticationFailed("user DN/password rejected by LDAP server.")
def _search_for_user_dn(self):
"""
This method was overridden because the AUTH_LDAP_USER_SEARCH