Created
June 20, 2010 19:32
-
-
Save eleddy/446035 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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