Blog
A very frequent request I get is how to change the default permissions assigned by Project Server to Project Workspace Sites for all projects, unfortunately this is not something that is configurable in Project Server so the only option out of the box is to disable the permissions sync and manage those permissions manually. Of course if you don’t want Administrators to manage every user manually this is not an option.
This is made more annoying if you want PM’s to be able to manage the site, as by default they only have Contribute like access.
There are a few options that exist out there, notably this one; Adjust the Default Project Web Access Permission Levels, which uses a SharePoint timer job to manage the default Permission Levels. However I have had need for something simpler, and so recently for a customer I implemented the following:
Modifying Basic Site Permissions using Project Events:
My solution is by intent extremely simple, so simple that I will include the main piece of code below (as well as having the full solution attached), in short what this code does is the following:
On Publish of any project does the following;
So as you can see it only updates one user’s permissions, however it would be trivial to update the code to do more based on the Project Team and other requirements.
Here is the bulk of the code:
----------------------------------------------------------------------------------------
if (wssData.ProjWssInfo.Count == 0)
{
LogEventEntry(String.Format("No workspace site found for project: {0}",
projectData.Project.First().PROJ_NAME), EventLogEntryType.Warning);
}
else {
// Open the SPSite and web
using (SPSite pwsSite = new SPSite(wssData.ProjWssInfo[0].PROJECT_WORKSPACE_URL))
{
using (SPWeb pwsWeb = pwsSite.OpenWeb())
{
// Handle Null Email Address
String ownerEmail;
if (resourceData.Resources.First().IsWRES_EMAILNull()) ownerEmail = "";
else ownerEmail = resourceData.Resources.First().WRES_EMAIL;
// Add the new role assignment to the Owner
SPRoleAssignment roleAssn =
new SPRoleAssignment(resourceData.Resources.First().WRES_ACCOUNT,
ownerEmail,
resourceData.Resources.First().RES_NAME,
"Project Owner");
SPRoleDefinition roleDefn =
pwsWeb.RoleDefinitions.GetByType(SPRoleType.Administrator);
roleAssn.RoleDefinitionBindings.Add(roleDefn);
pwsWeb.RoleAssignments.Add(roleAssn);
}
}
}
-----------------------------------------------------------
The code is bound to both OnPublished and OnSummaryPublished (to get the Save from PWA also), and ensures that the Owner will always have Admin rights, and if not all the PM has to do is republish.
Download only the WSP package here with – basic – instructions.
Download the full source package here.
Notes:
Post comments with any questions or additions even, but please note that I can’t provide support for the standalone WSP package.