diff --git a/lumi2/ldap.py b/lumi2/ldap.py index e3d3b81..0165ed8 100644 --- a/lumi2/ldap.py +++ b/lumi2/ldap.py @@ -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.