I’m creating an project management portal in SharePoint through Object Model, The very basic but still its a great little method called “RunWithElevatedPriveleges” helps me to run all the premission issues “The Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges method that enables me to supply a delegate that runs a subset of code in the context of an account with higher privileges than the current user.”
not only do the subset of code more than that like this…
/// <summary>
/// The method to invoke and handle the ItemAdded Event for the Project's List.
/// </summary>
/// <param name="properties">'properties' context for ItemAdding Event handler</param>
public override void ItemAdded(SPItemEventProperties properties)
{
ItemWorkspaceData itemWorkspaceData = this.GetItemWorkspaceData(properties);
if (itemWorkspaceData.strAfterListItemWorkspaceUrl != string.Empty)
{
SPWeb itemWorkspace = new SPSite(itemWorkspaceData.strAfterListItemWorkspaceUrl).OpenWeb();
Guid subGUID = itemWorkspace.ID;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
this.ProcessItemWorkspacePermissions(subGUID, itemWorkspace, properties);
});
itemWorkspace.Site.Dispose();
itemWorkspace.Dispose();
itemWorkspace = null;
}
}
}
/// <summary>
/// Sub Method to invoke the Project ItemWorkspace Permissions Settings...
/// </summary>
/// <param name="currentWeb">SPWeb, SpContext.Current.Web "current Web"</param>
/// <param name="strItemWorkSpaceUrl">String, sub Item WorkSpace server relative Url</param>
/// <param name="properties">'properties' context for respective event handler</param>
private void ProcessItemWorkspacePermissions(Guid Id, SPWeb currentWeb, SPItemEventProperties properties)
{
/// Adding the Project Item Workspace Permissions level Settings through Object model...
/// This piece of code runs absoultly good with no premission issues...
}
Cheers !!! Happy Coding…