DCSIMG
TFS API Part 12: Set Security For Area/Iteration - Shai Raiten's Blog

Shai Raiten's Blog

It's all about code...

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

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

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# February 11, 2009 10:50 AM

Shai Raiten said:

TFS API Summary & My #200 Post It’s been 4 months, 3 weeks(143 days) since my ..::: My #100 Post

# February 13, 2009 11:44 PM

aackose said:

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?

# October 18, 2010 10:55 AM

Raja said:

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?

# January 4, 2011 11:58 AM

shair said:

aackose,

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

# January 4, 2011 6:38 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: