Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
security.declareProtected(manage_users, 'getGroupedUsers')
def getGroupedUsers(self, groups=None):
""" Return all those users that are in a group """
all_dns = {}
users = []
member_attrs = list(Set(GROUP_MEMBER_MAP.values()))
if groups is None:
groups = self.getGroups()
for group_id, group_dn in groups:
group_details = self.getGroupDetails(group_id)
for key, vals in group_details:
if key in member_attrs or key == '':
# If the key is an empty string then the groups are
# stored inside the user folder itself.
for dn in vals:
all_dns[dn] = 1
for dn in all_dns.keys():
# Only attempt to retrieve the user if their DN
# matches the Users Base DN
+if not dn.count(self.users_base):
+ user = None
+else:
try:
user = self.getUserByDN(dn)
except:
user = None
if user is not None:
users.append(user.__of__(self))
return tuple(users)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.