Skip to content

Commit 86ab169

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

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-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: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,33 @@ 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(
80+
f"There are {len(children)} groups in the LDAP tree."
81+
)
7382

7483
# Add users to the users OU
7584
if self.debug:
76-
log.msg(f"Adding {len(oauth_adaptor.users)} users to the LDAP tree.")
85+
log.msg(
86+
f"Attempting to add {len(oauth_adaptor.users)} users to the LDAP tree."
87+
)
7788
for user_attrs in oauth_adaptor.users:
7889
users_ou.add_child(f"CN={user_attrs.cn}", user_attrs.to_dict())
90+
if self.debug:
91+
children = users_ou.list_children()
92+
for child in children:
93+
log.msg(f"... {child.dn.getText()}")
94+
log.msg(
95+
f"There are {len(children)} users in the LDAP tree."
96+
)
7997

8098
# Set last updated time
8199
log.msg("Finished building LDAP tree.")

0 commit comments

Comments
 (0)