Add or delete a specified permission for a project in a specified group in TFs C # code implementation

Source: Internet
Author: User
/// <Summary>
/// Add the specified permission to the specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Param name = "projectname"> project to which the Group belongs </param>
/// <Returns> </returns>
Public static string addpowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
Stringbuilder sp = new stringbuilder ();
SP. append ("/A + project frameworkglobalsecurity # permissionsname" + '"' +" N: [# projectname] \\# groupname "+ '"' + "Allow/collection: # collectionuri ");
Sp. Replace ("# permissionsname", permissionsname );
Sp. Replace ("# groupname", groupname );
Sp. Replace ("# projectname", projectname );
Sp. Replace ("# collectionuri", collectionuri );
Return sp. tostring ();
}

/// <Summary>
/// Remove a specified permission from a specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Param name = "projectname"> name of the team project, for example, surekamspm3 </param>
/// <Returns> </returns>
Public static string movepowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
Stringbuilder sp = new stringbuilder ();
SP. append ("/a-server frameworkglobalsecurity # permissionsname" + '"' +" N: [# projectname] \\# groupname "+ '"' + "Allow/collection: # collectionuri ");
Sp. Replace ("# permissionsname", permissionsname );
Sp. Replace ("# groupname", groupname );
Sp. Replace ("# projectname", projectname );
Sp. Replace ("# collectionuri", collectionuri );
Return sp. tostring ();
}

/// <Summary>
/// Call tfssecurity to grant the specified permission to the specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Returns> </returns>
Public static string excuteaddpowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
PROCESS p = new process ();
String sorted STR = addpowerforgroup (permissionsname, groupname, projectname, collectionuri );
P. startinfo. filename = "C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ common7 \ ide \ tfssecurity.exe ";

// Execute commands and Parameters
P. startinfo. Arguments = shortstr;
P. startinfo. useshellexecute = false; // close shell usage
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true; // you can specify not to display a window.
P. Start (); // start the process

String standardoutput = P. standardoutput. readtoend ();
String erroroutput = P. standarderror. readtoend ();
String message = standardoutput + "#" + erroutput;
Return message;
}

/// <Summary>
/// Delete the specified permission for the specified group
/// </Summary>
/// <Param name = "permissionsname"> permission name </param>
/// <Param name = "groupname"> group name </param>
/// <Returns> </returns>
Public static string excutemovepowerforgroup (string permissionsname, string groupname, string projectname, string collectionuri)
{
PROCESS p = new process ();
String inclustr = movepowerforgroup (permissionsname, groupname, projectname, collectionuri );
P. startinfo. filename = "C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ common7 \ ide \ tfssecurity.exe ";

// Execute commands and Parameters
P. startinfo. Arguments = shortstr;
P. startinfo. useshellexecute = false; // close shell usage
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true; // you can specify not to display a window.
P. Start (); // start the process

String standardoutput = P. standardoutput. readtoend ();
String erroroutput = P. standarderror. readtoend ();
String message = standardoutput + "#" + erroutput;
Return message;
}

/// <Summary>
/// Execute the command to obtain the permission group (Project Group) of all projects in the project set
/// </Summary>
/// <Param name = "collectionurl"> project URL, for example, http: // 10.2.11.35: 8080/TFS/surekamspm3 </param>
/// <Returns> return the correct output stream + "#" + error output stream </returns>
Public static string excutegetauthortygroup (string collectionurl)
{
PROCESS p = new process ();
String required STR = producecmd. getauthoritygroup (collectionurl );
P. startinfo. filename = "C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ common7 \ ide \ tfssecurity.exe ";

// Execute commands and Parameters
P. startinfo. Arguments = shortstr;
P. startinfo. useshellexecute = false; // close shell usage
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true; // you can specify not to display a window.
P. Start (); // start the process

String standardoutput = P. standardoutput. readtoend ();
String erroroutput = P. standarderror. readtoend ();
String message = standardoutput + "#" + erroutput;
Return message;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.