Click or drag to resize

RepositoryGetProtectionEntries Method

Get a list of Perforce protection entries for the passed-in file specs

Namespace:  Perforce.P4
Assembly:  p4api.net (in p4api.net.dll) Version: 2023.2.255.3501
Syntax
public IList<ProtectionEntry> GetProtectionEntries(
	IList<FileSpec> filespecs,
	Options options
)

Parameters

filespecs
Type: System.Collections.GenericIListFileSpec
options
Type: Perforce.P4Options

Return Value

Type: IListProtectionEntry
Remarks

p4 help protects

protects -- Display protections defined for a specified user and path

p4 protects [-a | -g group | -u user] [-h host] [-m] [file ...]

'p4 protects' displays the lines from the protections table that
apply to the current user. The protections table is managed using
the 'p4 protect' command.

If the -a flag is specified, protection lines for all users are
displayed. If the -g group flag or -u user flag is specified,
protection lines for that group or user are displayed.

If the -h host flag is specified, the protection lines that apply
to the specified host (IP address) are displayed.

If the -m flag is given, a single word summary of the maximum
access level is reported. Note that this summary does not take
exclusions or the specified file path into account.

If the file argument is specified, protection lines that apply to
the specified files are displayed.

The -a/-g/-u flags require 'super' access granted by 'p4 protect'.

Examples
To get the protections for the user tim for the entire server:
GetProtectionEntriesCmdOptions opts =
new GetProtectionEntriesCmdOptions(GetProtectionEntriesCmdFlags.None,
null, "tim", null);

FileSpec filespec =
new FileSpec(new DepotPath("//..."), null);
IList<FileSpec> filespecs = new List<FileSpec>();
filespecs.Add(filespec);

   IList<ProtectionEntry> target =
   Repository.GetProtectionEntries(filespecs, opts);
To get the protections summary for the group development tim for the entire server when connecting from IP address 10.24.4.6:
GetProtectionEntriesCmdOptions opts =
new GetProtectionEntriesCmdOptions(GetProtectionEntriesCmdFlags.AccessSummary,
"development", null, "10.24.4.6");

FileSpec filespec =
new FileSpec(new DepotPath("//..."), null);
IList<FileSpec> filespecs = new List<FileSpec>();
filespecs.Add(filespec);

   IList<ProtectionEntry> target =
   Repository.GetProtectionEntries(filespecs, opts);
See Also