The signature for SetPermissions method is:
public abstract AccessControlEntry SetPermissions(
string token,
IdentityDescriptor descriptor,
int allow,
int deny,
bool merge
)
Take the following snippet as example:
securityNamespace.SetPermissions("/", identity.Descriptor ,RegistryServicePermissions.AllPermissions, 0, true);
- token paremeter we will pass / which means we will be granting access
to the entire registry. If you want to grant just access to a part of
the tree, this is the place to do it
- identityDescriptor we will pass the account/group for which we will
be granting the parameter (more on this later)
- allow parameter we pass the value the value
RegistryServicePermissions.AllPermissions since we want to grant
read/write access
- deny parameter we will pass 0 since we don’t wan to deny anything
- merge we will pass true, since we want this permissions to be merged
with existing ones (just in case)
For more information, you could check the blog below:
https://pascoal.net/2011/11/13/using-team-foundation-server-registrypart-ii-the-api/
Also, here is a useful case for your reference: TFS API - How to get a Team's Adminstrator?.