承接MOSS各种工作流开发 联系人:王先生.电话:18618405729QQ:252385878 QQ群:41696750 MSN:wanghao-3@hotmail.com

导航

MOSS07权限分配问题!

           我们大家都直到,在SPS03和07里面 变化比较大的问题就是权限问题,
下面就是我操作07的权限分配代码,希望对各位开发人员有帮助
      SPWeb web = (new SPSite("http://moss/sites/hello/subweb")).OpenWeb();
                SPRoleDefinition newRole = new SPRoleDefinition();
                newRole.Name = "My Role";
                newRole.Description = "Role to view list items and pages.";
                newRole.BasePermissions = SPBasePermissions.ViewListItems | SPBasePermissions.ViewPages;
                if (!web.HasUniqueRoleDefinitions)
                    web.RoleDefinitions.BreakInheritance(true, true);
                web.RoleDefinitions.Add(newRole);

                SPList list = web.Lists["֪ͨ"];
                if (!list.HasUniqueRoleAssignments)
                    list.BreakRoleInheritance(true);
                SPRoleAssignment assignment = new SPRoleAssignment(web.EnsureUser("lhvm\wanghao")
                assignment.RoleDefinitionBindings.Add(web.RoleDefinitions["My Role"]);
                list.RoleAssignments.Add(assignment);

posted on 2007-06-13 09:17  A A  阅读(2778)  评论(5编辑  收藏  举报