Open sdiniz73 opened 5 years ago
Hello, has anyone managed to use "is member of"? I need to check if a user belongs to a group.
Thanks
I'm having the same issue.
Hello, has anyone managed to use "is member of"? I need to check if a user belongs to a group.
Thanks
I don't have push access, but i fixed that function:
def check_contains_member(self, check_member, recursive=False):
"""Checks whether a pyAD object is a member of the group.
check_member expects a pyAD object to be checked.
recursive expects True/False which determines whether the group membership will be searched recursively."""
user_list = self.get_members(recursive=recursive, ignoreGroups=False)
for checked_member in user_list:
user = 'cn=' + check_member
if user == checked_member.prefixed_cn:
is_true = True
break
else:
is_true = False
if is_true == True:
return True
else:
return False
@dexxfm Still give False every time :/
I use a workaround - checking if the guid_str of the user object exists in the list of guid_str of all group members. The only issue is that get_members() is slow...
pdl_members = pdl_obj.get_members()
if candidate.ad_user.guid_str in [member.guid_str for member in pdl_members]:
Hello, has anyone managed to use "is member of"? I need to check if a user belongs to a group.
Thanks