zoukankan      html  css  js  c++  java
  • SPRoleDefinition.BasePermissions 属性

    When assigning permissions to the BasePermissions property, you can use the following operators:

    • & - bitwise AND

    • ^ - exclusive OR

    • | - inclusive OR

    For Windows SharePoint Services permissions, you often work with each permission individually, so it is common to use ^ or | as operators.

    The following three lines illustrate operator usage:

    1) oRoleDefinition.BasePermissions |= SPBasePermissions.ManageSubwebs;

    Retains the current permissions mask but adds ManageSubwebs to the mask.

    2) oRoleDefinition.BasePermissions ^= SPBasePermissions.CreateSSCSite;

    Retains the current permissions mask but removes CreateSSCSite from the mask.

    3) oRoleDefinition.BasePermissions &= SPBasePermissions.CreateAlerts;

    Reduces the permissions mask so that it only contains CreateAlerts.

    The following code example shows how to modify the base permissions of a role definition that originally has full permissions to a Web site by excluding ManagePermissions.

     
    using (SPWeb oWebsite = SPContext.Current.Site.AllWebs["Subsite_Name"])
    {
        SPRoleDefinitionCollection collRoles = oWebsite.RoleDefinitions;
        SPRoleDefinition oRoleDefinition = collRoles["Definition_Name"];
        oRoleDefinition.BasePermissions = SPBasePermissions.FullMask ^ 
            SPBasePermissions.ManagePermissions;
    
        oRoleDefinition.Update();
    }
  • 相关阅读:
    Linq
    正则表达式
    XPath
    winFrom http协议
    CSS选择器
    Action方法
    Code First开发方式
    Database First开发方式
    可选参数,程序暂停,属性的初始化,String.Format改进
    Lambda表达式和LTNQ
  • 原文地址:https://www.cnblogs.com/liuxinls/p/2968751.html
Copyright © 2011-2022 走看看