您的位置:首页 > 其它

Create a New SharePoint Permission Level and Bind it to an Existing SharePoint Group

2008-01-17 09:59 666 查看
Create a New SharePoint Permission Level and Bind it to an Existing SharePoint Group
这个例子是新建一个  permission level,名字为Example_xxxxxxxxxxx.建好之后.绑定这个permission level 到一个已经存在的组名字为Foo.

using (SPSite site = new SPSite( "http://moss/sites/PermExample" ))

{

using (SPWeb rootWeb = site.RootWeb)

{

string permissionLevelName = "Example_"+System.DateTime.Now.Ticks.ToString();

// Create a new Permission Level

SPRoleDefinition newPermissionLevel = new SPRoleDefinition();

newPermissionLevel.Name = permissionLevelName;

newPermissionLevel.Description = "Example Permission Level";

newPermissionLevel.BasePermissions =

SPBasePermissions.AddListItems |

SPBasePermissions.BrowseDirectories |

SPBasePermissions.EditListItems |

SPBasePermissions.DeleteListItems |

SPBasePermissions.AddDelPrivateWebParts;

// Add the permission level to web

rootWeb.RoleDefinitions.Add(newPermissionLevel);

// Bind to the permission level we just added

newPermissionLevel = rootWeb.RoleDefinitions[permissionLevelName];

// Create a new role Assignment using the SharePoint Group "Foo"

SPRoleAssignment roleAssignment = new SPRoleAssignment( (SPPrincipal)rootWeb.SiteGroups[ "Foo" ] );

// Add the Permission Level to the Foo SharePoint Group

roleAssignment.RoleDefinitionBindings.Add(newPermissionLevel);

// Add the new Role Assignment to the web

rootWeb.RoleAssignments.Add(roleAssignment);

rootWeb.Close();

}

site.Close();

}

这样就新建成功了.也绑定到了已经存在的组.!

另一种是不写代码直接在网站上添加的方法

Create a permission level

If there is no permission level similar to the one you need, you can create one and include just the permissions that you need.

1:On the Site Settings page, under Users and Permissions, click Advanced permissions.

2:On the toolbar, click Settings, and then click Permission Levels.

3:On the toolbar, click Add a Permission Level.

4:On the Add a Permission Level page, in the Name box, type a name for the new permission level..

5:In the Description box, type a description for the new permission level..

6:In the list of permissions, select the check boxes to add permissions to the permission level

7:Click Create.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐