Get a list of groups from the repository

Namespace: Perforce.P4
Assembly: p4api.net (in p4api.net.dll) Version: 2017.3.160.836 (2017.3.160.0836)

Syntax

C#
public IList<Group> GetGroups(
	Options options,
	params string[] groups
)
Visual Basic
Public Function GetGroups ( _
	options As Options, _
	ParamArray groups As String() _
) As IList(Of Group)
Visual C++
public:
IList<Group^>^ GetGroups(
	Options^ options, 
	... array<String^>^ groups
)

Parameters

options
Type: Perforce.P4..::..Options
options for the groups commandGroupsCmdOptions
groups
Type: array<System..::..String>[]()[][]
groups

Return Value

A list containing the matching groups

Remarks


p4 help groups

groups -- List groups (of users)

p4 groups [-m max] [-v] [group]
p4 groups [-m max] [-i [-v]] user | group
p4 groups [-m max] [-g | -u | -o] name

The first form lists all user groups defined in the server, or just
the specified group.

The second form displays subgroup relationships. If a user argument is
specified, only groups containing that user are displayed. If a group
argument is specified, only groups containing the group are displayed.

The third form is useful when there are groups and users with the
same name, or when requesting all groups owned by a certain user.

The -i flag also displays groups that the user or group belongs to
indirectly by means of membership in subgroups.

The -m max flag limits output to the specified number of groups.

The -v flag displays the MaxResults, MaxScanRows, MaxLockTime, and
Timeout values for each group that is displayed.

The -g flag indicates that the 'name' argument is a group.

The -u flag indicates that the 'name' argument is a user.

The -o flag indicates that the 'name' argument is an owner.

Examples

To get the first 10 groups:
CopyC#
Options opts = new Options(GroupsCmdFlags.None, 10);
IList<Group> groups = _repository.getGroups(opts);
To get all groups that 'Bob' belongs to, including subgroups:
CopyC#
Options opts = new Options(GroupsCmdFlags.IncludeIndirect, -1);
IList<Group> groups = _repository.getGroups(opts, "Bob");
To get all the groups with the MaxResults, MaxScanRows, MaxLockTime, and Timeout values for the specified group:
CopyC#
Options opts = new Options(GroupsCmdFlags.IncludeAllValues, -1);
IList<Group> groups = _repository.getGroups(opts);

See Also