TFS API Part 12: Set Security For Area/Iteration

03/02/2009

3 comments

TFS API Part 12: Set Security For Area/Iteration

In the previous post I’ve talked about

image

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

image

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;

    }

}

 

image

image

Download Demo

Add comment
facebook linkedin twitter email

Leave a Reply

3 comments

  1. aackose18/10/2010 ב 10:55

    Shai! How can i get the AreaId of the new Area created? It would be great if i could get all the areaid’s in the server. I tried digging into the DB and not able to find them.

    The only option for me now is to save and go to the history tab to see the new id generated.

    Do you have any possibilities?

  2. Raja04/01/2011 ב 11:58

    When reading accesscontrol list, it retrieving duplicate access entry list like

    GENERIC_READ = false
    GENERIC_READ = true
    GENERIC_READ = false

    How can we identify the latest one?

  3. shair04/01/2011 ב 18:38

    aackose,
    You can use the code above to get new or any other area.