Last active
April 29, 2016 20:18
-
-
Save vlad-bezden/7560c7028c04a1b04b97df53b463dcaf to your computer and use it in GitHub Desktop.
Python example to check if user is in a group
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
# | |
# Code example to check if user is part of the group | |
# | |
import win32net | |
def if_user_in_group(group, member): | |
members = win32net.NetLocalGroupGetMembers(None, group, 1) | |
return member.lower() in list(map(lambda d: d['name'].lower(), members[0])) | |
# Function usage | |
print(if_user_in_group('SOME_GROUP', 'SOME_USER')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment