Skip to content

Commit 9ce7f3d

Browse files
committed
📝 Add debug messages for each group and user added to the LDAP tree
1 parent 44d6263 commit 9ce7f3d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

apricot/ldap/oauth_ldap_entry.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,6 @@ def _bind(password: bytes) -> "OAuthLDAPEntry":
8383
raise LDAPInvalidCredentials(msg)
8484

8585
return defer.maybeDeferred(_bind, password)
86+
87+
def list_children(self) -> "list[OAuthLDAPEntry]":
88+
return [cast(OAuthLDAPEntry, entry) for entry in self._children.values()]

apricot/ldap/oauth_ldap_tree.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,29 @@ def root(self) -> OAuthLDAPEntry:
6767

6868
# Add groups to the groups OU
6969
if self.debug:
70-
log.msg(f"Adding {len(oauth_adaptor.groups)} groups to the LDAP tree.")
70+
log.msg(
71+
f"Attempting to add {len(oauth_adaptor.groups)} groups to the LDAP tree."
72+
)
7173
for group_attrs in oauth_adaptor.groups:
7274
groups_ou.add_child(f"CN={group_attrs.cn}", group_attrs.to_dict())
75+
if self.debug:
76+
children = groups_ou.list_children()
77+
for child in children:
78+
log.msg(f"... {child.dn.getText()}")
79+
log.msg(f"There are {len(children)} groups in the LDAP tree.")
7380

7481
# Add users to the users OU
7582
if self.debug:
76-
log.msg(f"Adding {len(oauth_adaptor.users)} users to the LDAP tree.")
83+
log.msg(
84+
f"Attempting to add {len(oauth_adaptor.users)} users to the LDAP tree."
85+
)
7786
for user_attrs in oauth_adaptor.users:
7887
users_ou.add_child(f"CN={user_attrs.cn}", user_attrs.to_dict())
88+
if self.debug:
89+
children = users_ou.list_children()
90+
for child in children:
91+
log.msg(f"... {child.dn.getText()}")
92+
log.msg(f"There are {len(children)} users in the LDAP tree.")
7993

8094
# Set last updated time
8195
log.msg("Finished building LDAP tree.")

0 commit comments

Comments
 (0)