locked
Project server 2010 workspace data in VS 2010 RRS feed

  • Question

  • Hi,

    We need to programatically add /remove the users multiple workspaces, is it possible to do with visual studio programming. Normally it will be done using group, but when we use groups in worspace and add the users it will give access to all worspaces but we need to give permission to specific worspace.

    Thursday, February 16, 2012 3:09 AM

Answers

  • Hi there,

    Yes, you can do it programatically using the SPuser /SPGroup class of SharePoint object model. While the project is created, you can get the project workspace url from project server reporting database's table MSP_Project & once you have the url, you can trap the project server event like Onpublished & add the user to respective workpsace of the project.

    using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["Web_Site_Name"])
    {
        SPGroup oGroup = oWebsite.SiteGroups["Group_Name"];
        SPUserCollection collUsers = oWebsite.Users;
    
        foreach (SPUser oUser in collUsers)
        {
    oGroup.AddUser(oUser);
        }
    }

    For more info:
    http://msdn.microsoft.com/en-us/library/ie/ms454048.aspx
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spgroup.adduser.aspx

    Hope that helps.


    Thanks, Amit Khare |EPM Consultant| Blog: http://amitkhare82.blogspot.com http://www.linkedin.com/in/amitkhare82

    • Marked as answer by aruna22 Wednesday, March 7, 2012 2:35 PM
    Thursday, February 16, 2012 5:16 AM