MOSS07权限分配问题!
1 SPWeb web = (new SPSite("http://localhost/")).OpenWeb();
2SPRoleDefinition newRole = new SPRoleDefinition();
3newRole.Name = "My Role";
4newRole.Description = "Role to view list items and pages.";
5newRole.BasePermissions = SPBasePermissions.ViewListItems | SPBasePermissions.ViewPages;
6if (!web.HasUniqueRoleDefinitions)
7web.RoleDefinitions.BreakInheritance(true, true);
8web.RoleDefinitions.Add(newRole);
9
10SPList list = web.Lists["Test"];
11if (!list.HasUniqueRoleAssignments)
12list.BreakRoleInheritance(true);
13SPRoleAssignment assignment = new SPRoleAssignment(web.EnsureUser("lhvmwanghao")
14assignment.RoleDefinitionBindings.Add(web.RoleDefinitions["My Role"]);
15list.RoleAssignments.Add(assignment);
16
17
18
2SPRoleDefinition newRole = new SPRoleDefinition();
3newRole.Name = "My Role";
4newRole.Description = "Role to view list items and pages.";
5newRole.BasePermissions = SPBasePermissions.ViewListItems | SPBasePermissions.ViewPages;
6if (!web.HasUniqueRoleDefinitions)
7web.RoleDefinitions.BreakInheritance(true, true);
8web.RoleDefinitions.Add(newRole);
9
10SPList list = web.Lists["Test"];
11if (!list.HasUniqueRoleAssignments)
12list.BreakRoleInheritance(true);
13SPRoleAssignment assignment = new SPRoleAssignment(web.EnsureUser("lhvmwanghao")
14assignment.RoleDefinitionBindings.Add(web.RoleDefinitions["My Role"]);
15list.RoleAssignments.Add(assignment);
16
17
18