SPSite spSite= null;
SPWeb spWeb = null;
using(spSite = new SPSite("SiteUrl")
{
spWeb= spSite.OpenWeb();
spWeb.AllowUnSafeUpdates = true;
SPRoleAssignment spRoleAssignment = new SPRoleAssignment ("domain\\UserName","alias@domain.com","UserName","Test Message");
SPRoleDefinition spRoleDefinition = spWeb.RoleDefinitions.GetByType(SPRoleType.
Administrator);
spRoleAssignment.RoleDefinitionBindings.Add(spRoleDefinition);
spWeb.RoleAssignments.Add(spRoleAssignment);
spWeb.Dispose();
spWeb.AllowUnSafeUpdates = false;
}
1 comment:
Wow. I was trying to do the same and written few lines similar to your but failed to carry out the whole task. Its so nice of you that you have posted the whole cose to set permissions to the site. Thanks a lot.
electronic signature for sharepoint
Post a Comment