TFS API Part 12: Set Security For Area/Iteration
TFS API Part 12: Set Security For Area/Iteration
In the previous post I’ve talked about
Download Demo
First add reference for Microsoft.TeamFoundation, Microsoft.TeamFoundation.Client, Microsoft.TeamFoundation.Common.dll,Microsoft.TeamFoundation.WorkItemTracking.Client.dll
located in - C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\
Add using for:
using Microsoft.TeamFoundation.Proxy;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.Client;
Here is the list for the Security Types:
GENERIC_READ
GENERIC_WRITE
CREATE_CHILDREN
WORK_ITEM_WRITE
WORK_ITEM_READ
DELETE
Using IAuthorizationService. AddAccessControlEntry to add AccessControlEntry.
AccessControlEntry(string actionId,string sid,bool deny)
New static method to AccessControl.
public static string SetAccessControl(TeamFoundationServer tfs, string action,
string sid, string nodeUri,bool type)
{
try
{
IAuthorizationService auth = (IAuthorizationService)tfs.GetService(typeof(IAuthorizationService));
// Add security for user.
auth.AddAccessControlEntry(nodeUri, new AccessControlEntry(action, sid, type));
return "OK";
}
catch(Exception ex)
{
return ex.Message;
}
}


Download Demo