feat(ldap): create function for user existence check
This commit is contained in:
parent
08ad0b4474
commit
5145f3a4e8
@ -553,6 +553,32 @@ def create_ou(connection: Connection, ou_dn: str) -> None:
|
||||
connection.add(ou_dn, 'organizationalUnit')
|
||||
|
||||
|
||||
def user_exists(connection: Connection, user_dn: str) -> bool:
|
||||
"""Checks whether the specified user entry exists in the DIT.
|
||||
|
||||
The user DN is expected to represent an entry which is a direct child of the
|
||||
LDAP_USERS_OU specified in the app config.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
Connection : ldap3.Connection
|
||||
Bound Connection object to an LDAP server.
|
||||
ou_dn : str
|
||||
DN of a user entry (uid) directly below the LDAP_USERS_OU entry.
|
||||
|
||||
Raises
|
||||
------
|
||||
MissingParentEntryException
|
||||
If the specified user DN's direct parent entry is not present in the DIT.
|
||||
"""
|
||||
|
||||
_assert_is_valid_connection(connection)
|
||||
_assert_is_valid_user_dn(user_dn)
|
||||
|
||||
# TODO implement
|
||||
return False
|
||||
|
||||
|
||||
def get_user(connection: Connection, uid: str) -> User:
|
||||
"""Retrieves the user with the specified uid (username) from the LDAP server.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user