Is it possible to use the TFS SDK to query and edit Server Access Levels (Stakeholder, Basic, Advanced)

304 Views Asked by At

I'm currently using TFS 2013 (On Premise). I'm unable to find a way to programmatically query the lists of 'Stakeholder', 'Basic' and 'Advanced' users, set in the 'Access Levels' tab of the Control Panel at server level, or, given a valid TeamFoundationIdentity, find out what their corresponding access level is. Is it possible to do this?

I am quite familiar with using the SDK, although only reasonably so when looking up users and security. As an example, I know how to list all Project Collection Valid Users across the server.

TfsConfigurationServer configurationServer

IIdentityManagementService ims = configurationServer.GetService<IIdentityManagementService>();

TeamFoundationIdentity[][] identities = ims.ReadIdentities(IdentitySearchFactor.AccountName,
        new[] { "Project Collection Valid Users" }, MembershipQuery.Expanded, ReadIdentityOptions.ExtendedProperties);

Any help will be greatly appreciated, thanks.

2

There are 2 best solutions below

2
On

You can read access level of a user using REST Client API.

String collectionUri = "https://{account}.visualstudio.com";
VssCredentials creds = new VssClientCredentials();
creds.Storage = new VssClientCredentialStorage();
VssConnection connection = new VssConnection(new Uri(collectionUri), creds);
var licensingHttpClient = connection.GetClient<LicensingHttpClient>();
var accountEntitlement = licensingHttpClient.GetAccountEntitlementAsync().Result;
var license = accountEntitlement.License;
0
On

No, it’s impossible.

It seems there is no official document about how to querying and edit Server Access Level using TFS API.

Please refer to the discussions in below similar posts: https://social.msdn.microsoft.com/Forums/vstudio/en-US/222245c1-5f72-4daa-bc0f-a038ee363bd8/querying-tfs-user-access-level-via-the-object-model?forum=tfsgeneral