The tool to use is tfssecurity.exe with /g+ option. IGroupSecurityService has AddMemberToApplicationGroup method to add users to a group. You could get identity of an account using ReadIdentityFromSource method.
Here is a sample for using IGroupSecruityService and getting list of user identities in a group
IGroupSecurityService sec = (IGroupSecurityService)tfsServer.GetService(typeof(IGroupSecurityService));
TeamProject tp = tfsClient.GetTeamProject(teamProject);
Identity[] appGroups = sec.ListApplicationGroups(tp.ArtifactUri.AbsoluteUri);
foreach (Identity group in appGroups)
{
Identity[] groupMembers = sec.ReadIdentities(SearchFactor.Sid, new string[] { group.Sid }, QueryMembership.Expanded);
foreach (Identity member in groupMembers)
{
Console.WriteLine(member.DisplayName);
if (member.Members != null)
{
foreach (string memberSid in member.Members)
{
Identity memberInfo = sec.ReadIdentity(SearchFactor.Sid, memberSid, QueryMembership.None);
Console.WriteLine(" {0}", memberInfo.DisplayName);
}
}
}
}
|