SPUser CurrentUser = _MyWeb.CurrentUser; GrantUserPermission(folder, _MyWeb, SPRoleType.Contributor, CurrentUser); private static void GrantUserPermission (SPFolder CurrentListItem, SPWeboSPWeb, SPRoleType SPRoleType, SPPrincipal SPPrincipal)
{ SPRoleDefinition oSPRoleDefinition = oSPWeb.RoleDefinitions.GetByType(SPRoleType); SPRoleAssignment oSPRoleAssignment = new SPRoleAssignment(SPPrincipal); oSPRoleAssignment.RoleDefinitionBindings.Add(oSPRoleDefinition); CurrentListItem.Item.RoleAssignments.Add(oSPRoleAssignment); CurrentListItem.Update(); } |