Skip to content

Instantly share code, notes, and snippets.

@vlad-bezden
Last active April 29, 2016 20:18
Show Gist options
  • Save vlad-bezden/7560c7028c04a1b04b97df53b463dcaf to your computer and use it in GitHub Desktop.
Save vlad-bezden/7560c7028c04a1b04b97df53b463dcaf to your computer and use it in GitHub Desktop.
Python example to check if user is in a group
#
# 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