开发者

Assigning Group's Permission to Document libraries

Here is the scenario..

===== scanario 1 ===== 1. Document Library "Gatorate Classic" 2. I have four groups. Group Alpha - Role - Read Group Beta - Role - Edit Group Epselon - Role - Edit Group Gamma - Role - Edit

===== scanario开发者_如何学编程 2 ===== 1. Document Library "Gatorate G2" 2. I have four groups. Group Alpha - Role - Edit Group Beta - Role - Read Group Epselon - Role - Edit Group Gamma - Role - Read


I tried to follow this link but http://www.csharpest.net/?p=74 but i dont think this is my solution. Did anyone had a scenario like this. Same group but different level access.


I Have something where I change the permission level on a Document Library (with Pages) but I have a different need so I built privileges on the pages.

            string groupname = "Group Alpha";
            SPWeb web = getSPWeb();
            web.AllowUnsafeUpdates = true;
            SPGroup grupo = web.Groups[groupname];
            SPFile arq = null;
            SPFolder pasta = web.GetFolder("pages");
            arq = pasta.Files["page1.aspx"];

            if (arq.InDocumentLibrary)
            {
                SPListItem item = arq.Item;
                if (!item.HasUniqueRoleAssignments)
                    item.BreakRoleInheritance(false);
                SPRoleAssignmentCollection roles = item.RoleAssignments;
                while (roles.Count > 0)
                    roles.Remove(0);

                SPRoleAssignment atrib1 = new SPRoleAssignment(web.Groups[groupname] as SPPrincipal);
                atrib1.RoleDefinitionBindings.Add(web.RoleDefinitions.GetByType(SPRoleType.Administrator));
                roles.Add(atrib1);

            }
            web.AllowUnsafeUpdates = false;

Hopes this helps you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜