Answered Workspace permission using TFS api

  • Tuesday, March 15, 2011 11:59 AM
     
     

    Hi,

    I need to change the permissions other users workspaces.

    The workspace is actually private and i need to change it to public to perform some operations and after back to private.

    with command line i can perform this:

    tf workspace /collection:COLLECTION WORKSPACE;USER /permission:Private|Public

    there is a way to make this using the api?

    Thanks

     


    LeoLambertucci

All Replies

  • Thursday, March 17, 2011 12:02 PM
    Moderator
     
     Answered

    Hi LeoLambertucci,

     

    Thanks for your post.

     

    For how to change the Workspace’s permission using TFS API, please refer to this blog: http://blogs.msdn.com/b/phkelley/archive/2010/02/04/improvements-to-workspaces-in-tfs-2010.aspx 

     

    // Use the current directory to infer the workspace and TFS team project collection.

    WorkspaceInfo wi = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory);

    TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(wi.ServerUri);

    VersionControlServer vcs = tpc.GetService<VersionControlServer>();

    Workspace workspace = vcs.GetWorkspace(wi);

     

    // Get the identity service for the TPC.

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

     

    // Get the security service for the TPC and use it to get the workspace security namespace.

    ISecurityService security = tpc.GetService<ISecurityService>();

    SecurityNamespace workspaceSecurityNamespace =

                           security.GetSecurityNamespace(SecurityConstants.WorkspaceSecurityNamespaceGuid);

     

    // Get the access control list for the workspace, using the workspace's security token in the namespace.

    AccessControlList acl = workspaceSecurityNamespace.QueryAccessControlList(workspace.SecurityToken,

                            null, false);

     


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.