def _ldap_authenticate(username, password):
"""Performs a search bind to authenticate a user.
LDAP server details are defined in :doc:`config`.
:param username: LDAP username
:param password: LDAP password
:return: Returns a tuple of user_info and authentication status
:rtype: tuple
"""
user = ldap3_manager.get_user_info_for_username(username)
ldap_auth = ldap3_manager.authenticate_search_bind(username, password)
if ldap_auth.status is AuthenticationResponseStatus.success:
authenticated = True
else:
authenticated = False
return user, authenticated
评论列表
文章目录