def get_group_membership(username):
"""
Returns a list of groups the user is a member of to support Role-Based Access Control.
The `id` command is used because it reports all (POSIX) groups that the user
is a member of including external groups from Identity Management systems (AD, IdM, FreeIPA).
Arguments
----------
username : string
the username to get group membership for
"""
exe = find_executable('id')
p = subprocess.Popen([exe, '-Gn', username], stdout=subprocess.PIPE)
groups = p.stdout.read().split()
groups.remove(username)
return groups
评论列表
文章目录