SPList.EffectiveBasePermissions 属性
获取当前用户的有效基准权限列表中,包括其组成员身份和策略。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Overrides ReadOnly Property EffectiveBasePermissions As SPBasePermissions
Get
用法
Dim instance As SPList
Dim value As SPBasePermissions
value = instance.EffectiveBasePermissions
public override SPBasePermissions EffectiveBasePermissions { get; }
属性值
类型:Microsoft.SharePoint.SPBasePermissions
指定当前用户具有列表的有效权限枚举值的按位组合。
实现
ISecurableObject.EffectiveBasePermissions
示例
下面的示例是一个控制台应用程序检查当前用户是否在网站的共享文档列表上具有SPBasePermissions.ApproveItems权限。
Imports System
Imports Microsoft.SharePoint
Module Test
Sub Main()
Using site As SPSite = New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
' Get a list to check permissions on.
Dim listUrl As String = web.RootFolder.ServerRelativeUrl + "shared documents"
Dim list As SPList = web.GetList(listUrl)
' Get the current user's rights mask for the list.
Dim permMask As SPBasePermissions = list.EffectiveBasePermissions
' Check for a specific permission.
Dim hasPermission As Boolean = (permMask & SPBasePermissions.ApproveItems) <> 0
Console.WriteLine(hasPermission)
End Using
End Using
Console.Write(vbCrLf + "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
// Get a list to check permissions on.
string listUrl = web.RootFolder.ServerRelativeUrl + "shared documents";
SPList list = web.GetList(listUrl);
// Get the current user's rights mask for the list.
SPBasePermissions permMask = list.EffectiveBasePermissions;
// Check for a specific permission.
bool hasPermission = (permMask & SPBasePermissions.ApproveItems) != 0;
Console.WriteLine(hasPermission);
}
}
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
}