Last active
April 4, 2018 23:20
-
-
Save mayankiitg/9c71e82e085a8eed8f88f90326cfebd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Identity amit; | |
string projectName = "VSOnline"; | |
Guid projectId; | |
{ | |
ProjectHttpClient client = connection.GetClient<ProjectHttpClient>(); | |
var projects = client.GetProjects().SyncResult(); | |
projectId = projects.Single(s => StringComparer.OrdinalIgnoreCase.Equals(s.Name, projectName)).Id; | |
} | |
{ | |
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>(); | |
var rootAreaId = witClient.GetClassificationNodeAsync(projectId, TreeStructureGroup.Areas, depth: 0).SyncResult().Identifier; | |
Guid namespaceId = WitConstants.SecurityConstants.CommonStructureNodeSecurityNamespaceGuid; | |
var securityToken = WitConstants.SecurityConstants.GetRootClassificationNodeToken(rootAreaId.ToString()); | |
int allow = WitConstants.SecurityConstants.AuthorizationCssNodePermissions.WorkItemRead | | |
WitConstants.SecurityConstants.AuthorizationCssNodePermissions.WorkItemWrite; | |
int deny = WitConstants.SecurityConstants.AuthorizationCssNodePermissions.Delete; | |
SecurityHttpClient client = connection.GetClient<SecurityHttpClient>(); | |
client.SetAccessControlEntriesAsync( | |
namespaceId, | |
securityToken, | |
new AccessControlEntry[] | |
{ | |
new AccessControlEntry() | |
{ | |
Descriptor = amit.Descriptor, | |
Allow = allow, | |
Deny = deny | |
} | |
}, | |
merge: false).SyncResult(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment