当前位置: 首页>>代码示例>>C#>>正文


C# SPWeb.BreakRoleInheritance方法代码示例

本文整理汇总了C#中SPWeb.BreakRoleInheritance方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.BreakRoleInheritance方法的具体用法?C# SPWeb.BreakRoleInheritance怎么用?C# SPWeb.BreakRoleInheritance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SPWeb的用法示例。


在下文中一共展示了SPWeb.BreakRoleInheritance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BreakRoleInheritance

        /// <summary>
        /// The function to Break permission of Web
        /// </summary>
        /// <param name="web">Current Web</param>
        /// <param name="copyRoleAssigements">Copy permission of parrent?</param>
        public static void BreakRoleInheritance(SPWeb web, bool copyRoleAssigements)
        {
            if (web.IsRootWeb)
            {
                return;
            }

            web.BreakRoleInheritance(copyRoleAssigements);

            if (!web.HasUniqueRoleDefinitions)
            {
                web.RoleDefinitions.BreakInheritance(false, copyRoleAssigements);
            }
        }
开发者ID:setsunafjava,项目名称:vpsp,代码行数:19,代码来源:SecurityHelper.cs

示例2: GrantGroupSiteLevelPermissions

        /// <summary>
        /// Grants permissions to a group for a specific site.
        /// </summary>
        /// <param name="spGroup">Represents a SharePoint group</param>
        /// <param name="sPRoleType">Represents the permission to grant to the target group.</param>
        /// <param name="spWeb">Represents an instance of the Homework Tracking Site as a SPWeb object.</param>
        private static void GrantGroupSiteLevelPermissions(SPGroup spTargetGroup, SPRoleType sPRoleType, SPWeb spWeb)
        {
            if (!spWeb.IsRootWeb)
            {

                if (spWeb.HasUniqueRoleAssignments == false)
                {
                    spWeb.BreakRoleInheritance(true);
                }
                /* Adding the School Administration group. */
                spWeb.RoleAssignments.Remove(spTargetGroup);
                SPRoleAssignment roleAssign = new SPRoleAssignment(spTargetGroup);
                SPRoleDefinition roleDef = spWeb.RoleDefinitions.GetByType(sPRoleType);
                roleAssign.RoleDefinitionBindings.Add(roleDef);
                spWeb.RoleAssignments.Add(roleAssign);

            }
        }
开发者ID:brandonmichaelhunter,项目名称:SharePoint-Solutions,代码行数:24,代码来源:SecurityGroups.cs

示例3: SetUpDocumentWorkspace

        private void SetUpDocumentWorkspace(SPItemEventProperties eventProperties, SPSite rootWeb, SPWeb documentWorkspace)
        {
            //First change the permissions for the documentWorkspace
               documentWorkspace.AllowUnsafeUpdates = true;
               documentWorkspace.BreakRoleInheritance(false);

               string agendaType = eventProperties.ListItem["AgendaType"].ToString();
               string agmOffice = eventProperties.ListItem["AGM Office"].ToString();

               try
               {
               SPFieldUserValueCollection authUsers = PaperLessBoardHelper.GetKeyPeopleForAgenda(agendaType, agmOffice, eventProperties);
               foreach (SPFieldUserValue userValue in authUsers)
               {
                   SPRoleAssignment role;

                   role = new SPRoleAssignment(eventProperties.Web.EnsureUser(userValue.LookupValue));

                   role.RoleDefinitionBindings.Add(documentWorkspace.RoleDefinitions.GetByType(SPRoleType.Contributor));

                   documentWorkspace.RoleAssignments.Add(role);
                   documentWorkspace.Update();
               }
               //In addition the following groups get certain permissions
               //TODO: These permissions should ideally come from configuration

               SPGroup agendaCoordinators = eventProperties.Web.Groups["Agenda Coordinators"];
               SPRoleDefinition roleDefForAgendaCoordinators = eventProperties.Web.RoleDefinitions["Read"];

               SPRoleAssignment roleForAgendaCoordinators = new SPRoleAssignment(agendaCoordinators);
               roleForAgendaCoordinators.RoleDefinitionBindings.Add(roleDefForAgendaCoordinators);
               documentWorkspace.RoleAssignments.Add(roleForAgendaCoordinators);
               documentWorkspace.Update();

               SPGroup emisPortalMembers = eventProperties.Web.Groups["EMIS Portal Members"];
               SPRoleDefinition roleDefForEmisPortalMembers = eventProperties.Web.RoleDefinitions["Restricted Contribute"];
               SPRoleAssignment roleForEmisPortalMembers = new SPRoleAssignment(emisPortalMembers);
               roleForEmisPortalMembers.RoleDefinitionBindings.Add(roleDefForEmisPortalMembers);
               documentWorkspace.RoleAssignments.Add(roleForEmisPortalMembers);
               documentWorkspace.Update();

               SPGroup boardOfficeMembers = eventProperties.Web.Groups["Board Office Members"];
               SPRoleDefinition roleDefForBoardOfficeMemebers = eventProperties.Web.RoleDefinitions["Full Control"];
               SPRoleAssignment roleForBoardOfficeMembers = new SPRoleAssignment(boardOfficeMembers);
               roleForBoardOfficeMembers.RoleDefinitionBindings.Add(roleDefForBoardOfficeMemebers);
               documentWorkspace.RoleAssignments.Add(roleForBoardOfficeMembers);
               documentWorkspace.Update();

               SPGroup cpmManagers = eventProperties.Web.Groups["CPM Managers"];
               SPRoleDefinition roleDefForCPMManagers = eventProperties.Web.RoleDefinitions["Restricted Contribute"];
               SPRoleAssignment roleForCPMManagers = new SPRoleAssignment(cpmManagers);
               roleForCPMManagers.RoleDefinitionBindings.Add(roleDefForCPMManagers);
               documentWorkspace.RoleAssignments.Add(roleForCPMManagers);
               documentWorkspace.Update();

               }
               catch (Exception exc)
               {
               Microsoft.Office.Server.Diagnostics.PortalLog.LogString("Exception – {0} – {1} – {2}", "Board Agenda Receiver Error while adding Key People and setting Permissions in workspace", exc.Message, exc.StackTrace);
               }
            //Make sure it inherits the theme from the rootWeb
            string currentTheme = rootWeb.RootWeb.Theme;
            documentWorkspace.ApplyTheme(currentTheme);

            string docSetName = "Agenda Workspace DS-6";
            string defaultDocumentsLibraryName = null;
            string libraryNameInDocumentWorkspace = null;
            string boardSiteURL = null;
            string boardMeetingListName = null;
            string lookAheadListName = null;
            string masterKeyPeopleListName = null;
            SPContentType newDocumentSetContentType = null;

               //SPFolder defaultDocuments =rootWeb.RootWeb.Folders["Default Documents"];
               SPWebApplication webApplication = eventProperties.Web.Site.WebApplication;
               if (webApplication.Properties != null && webApplication.Properties.Count > 0)
               {
               if (webApplication.Properties.ContainsKey("DefaultDocumentsLibrary"))
               {
                   defaultDocumentsLibraryName = webApplication.Properties["DefaultDocumentsLibrary"].ToString();
                   libraryNameInDocumentWorkspace = webApplication.Properties["LibraryNameInDocumentWorkspace"].ToString();
                   boardSiteURL = webApplication.Properties["BoardSiteURL"].ToString();
                   boardMeetingListName = webApplication.Properties["BoardMeetingListName"].ToString();
                   lookAheadListName = webApplication.Properties["LookAheadListName"].ToString();
                   lookAheadListName = webApplication.Properties["LookAheadListName"].ToString();
                   masterKeyPeopleListName = webApplication.Properties["MasterKeyPeopleListName"].ToString();
               }
               }

               DocumentSetTemplate newDocumentSetTemplate = null;

               if (eventProperties.ListItem["AgendaType"].ToString() == "Procurement Resolution")
               {
               docSetName = DocSetNames.ProcurementResolution;

               if (rootWeb.RootWeb.ContentTypes[docSetName] == null)
               {
                   // create the new document set content Type
                   newDocumentSetContentType = rootWeb.RootWeb.ContentTypes.Add(new SPContentType(rootWeb.RootWeb.ContentTypes["Document Set"], rootWeb.RootWeb.ContentTypes, docSetName));

//.........这里部分代码省略.........
开发者ID:kawalgrover,项目名称:MARTA-Projects,代码行数:101,代码来源:BoardAgendaReceiver.cs

示例4: SetAnonymousAccessToAll

 /// <summary>
 /// Sets the anonymous access to all authenticated.
 /// </summary>
 /// <param name="web">The web.</param>
 /// <param name="oItem">The o item.</param>
 /// <param name="user">The user.</param>
 /// <exception cref="System.Exception"></exception>
 public static void SetAnonymousAccessToAll(SPWeb web, SPItem oItem, string user)
 {
     if (web.Url == "/") return;
     switch (oItem["VisibleBy"].ToString())
     {
         //SharepointAdminsOnly
         case "AuthenticatedUsers":
             // check if it has unique permissions
             if (!web.HasUniqueRoleAssignments)
             {
                 //This method breaks the role assignment inheritance
                 //for the list item, and creates unique role assignments
                 //for the list item with the copyRoleAssignments parameter
                 //which specifies whether to copy role assignments from the
                 //parent object and with the clearSubscopes parameter which
                 //specifies whether to clear role assignments from child objects.
                 web.BreakRoleInheritance(true, false);
             }
             switch (DetectSiteLanguage(web))
             {
                 //pt-PT
                 case 2070:
                     web.Groups["Visualizadores"].Users.Add(user, null, null, null);
                     break;
                 //eng-USA
                 case 1033:
                     web.Groups["Viewers"].Users.Add(user, null, null, null);
                     break;
                 default:
                     throw new Exception("Not Supported Language!");
             }
             break;
     }
 }
开发者ID:DevScope,项目名称:SPEduQuickStart,代码行数:41,代码来源:SPGenerateHelpers.cs


注:本文中的SPWeb.BreakRoleInheritance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。