MCPcopy
hub / github.com/saltstack/salt / list_groups

Function list_groups

salt/modules/win_useradd.py:931–956  ·  view source on GitHub ↗

Return a list of groups the named user belongs to Args: name (str): The username for which to list groups Returns: list: A list of groups to which the user belongs CLI Example: .. code-block:: bash salt '*' user.list_groups foo

(name)

Source from the content-addressed store, hash-verified

929
930
931def list_groups(name):
932 """
933 Return a list of groups the named user belongs to
934
935 Args:
936
937 name (str): The username for which to list groups
938
939 Returns:
940 list: A list of groups to which the user belongs
941
942 CLI Example:
943
944 .. code-block:: bash
945
946 salt '*' user.list_groups foo
947 """
948 ugrp = set()
949 try:
950 user = info(name)["groups"]
951 except KeyError:
952 return False
953 for group in user:
954 ugrp.add(group.strip(" *"))
955
956 return sorted(list(ugrp))
957
958
959def getent(refresh=False):

Callers 1

chgroupsFunction · 0.70

Calls 4

setFunction · 0.70
infoFunction · 0.70
listFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected