IAuthorizationExtension.CheckAccess 方法

定义

指示是否授权用户来访问报表服务器数据库中给定操作的项。

重载

CheckAccess(String, IntPtr, Byte[], CatalogOperation)

指示是否授权用户来访问报表服务器数据库中给定目录操作的项。

CheckAccess(String, IntPtr, Byte[], CatalogOperation[])

指示是否授权用户来访问报表服务器数据库中给定目录操作数组的项。

CheckAccess(String, IntPtr, Byte[], DatasourceOperation)

指示是否授权用户来访问报表服务器数据库中给定数据源操作的项。

CheckAccess(String, IntPtr, Byte[], FolderOperation)

指示是否授权用户来访问报表服务器数据库中给定文件夹操作的项。

CheckAccess(String, IntPtr, Byte[], FolderOperation[])

根据报表服务器数据库中某一项的操作的安全描述符,检查用户的授权凭据。

CheckAccess(String, IntPtr, Byte[], ModelItemOperation)

指示是否授权用户来访问报表服务器数据库中给定模型项操作的项。

CheckAccess(String, IntPtr, Byte[], ModelOperation)

指示用户是否有权访问报表服务器数据库中给定模型操作的项的值。

CheckAccess(String, IntPtr, Byte[], ReportOperation)

指示是否授权用户来访问报表服务器数据库中给定报表操作的项。

CheckAccess(String, IntPtr, Byte[], ResourceOperation)

指示是否授权用户来访问报表服务器数据库中给定资源操作的项。

CheckAccess(String, IntPtr, Byte[], ResourceOperation[])

指示是否授权用户来访问报表服务器数据库中给定资源操作数组的项。

CheckAccess(String, IntPtr, Byte[], CatalogOperation)

指示是否授权用户来访问报表服务器数据库中给定目录操作的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, Microsoft::ReportingServices::Interfaces::CatalogOperation requiredOperation);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.CatalogOperation requiredOperation);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.CatalogOperation -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperation As CatalogOperation) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperation
CatalogOperation

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。

Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperation As CatalogOperation) As Boolean  
   Dim acl As AceCollection = DeserializeAcl(secDesc)  
   Dim ace As AceStruct  
   For Each ace In  acl  
      ' First check to see if the user or group has an access control entry for the item  
      If userName = ace.PrincipalName Then  
         ' If an entry is found, return true if the given required operation  
         ' is contained in the ACE structure.  
         Dim aclOperation As CatalogOperation  
         For Each aclOperation In  ace.CatalogOperations  
            If aclOperation = requiredOperation Then  
               Return True  
            End If  
         Next aclOperation  
      End If  
   Next ace  
   Return False  
End Function 'CheckAccess  

Private Function DeserializeAcl(secDesc() As Byte) As AceCollection  
   Dim bf As New BinaryFormatter()  
   Dim sdStream As New MemoryStream(secDesc)  
   Dim acl As AceCollection = CType(bf.Deserialize(sdStream), AceCollection)  
   Return acl  
End Function 'DeserializeAcl  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, CatalogOperation requiredOperation)  
{  
   AceCollection acl = DeserializeAcl(secDesc);  
   foreach(AceStruct ace in acl)  
   {  
       // First check to see if the user or group has an access control entry for the item  
      if (userName == ace.PrincipalName)  
      {  
          // If an entry is found, return true if the given required operation  
          // is contained in the ACE structure.  
         foreach(CatalogOperation aclOperation in ace.CatalogOperations)  
         {  
             if (aclOperation == requiredOperation)  
                return true;  
         }  
      }  
   }  
   return false;  
}  

private AceCollection DeserializeAcl(byte[] secDesc)  
{  
   BinaryFormatter bf = new BinaryFormatter();  
   MemoryStream sdStream = new MemoryStream(secDesc);  
   AceCollection acl = (AceCollection)bf.Deserialize(sdStream);  
   return acl;  
}  

适用于

CheckAccess(String, IntPtr, Byte[], CatalogOperation[])

指示是否授权用户来访问报表服务器数据库中给定目录操作数组的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, cli::array <Microsoft::ReportingServices::Interfaces::CatalogOperation> ^ requiredOperations);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.CatalogOperation[] requiredOperations);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.CatalogOperation[] -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperations As CatalogOperation()) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperations
CatalogOperation[]

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。 此示例使用重载的 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法,该方法采用单个操作作为参数。

' Overload for array of catalog operations  
Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperations() As CatalogOperation) As Boolean  
   Dim operation As CatalogOperation  
   For Each operation In  requiredOperations  
      If Not CheckAccess(userName, userToken, secDesc, operation) Then  
         Return False  
      End If  
   Next operation  
   Return True  
End Function 'CheckAccess  
// Overload for array of catalog operations  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, CatalogOperation[] requiredOperations)  
{  
   foreach(CatalogOperation operation in requiredOperations)  
   {  
      if (!CheckAccess(userName, userToken, secDesc, operation))  
         return false;  
   }  
   return true;   
}  

适用于

CheckAccess(String, IntPtr, Byte[], DatasourceOperation)

指示是否授权用户来访问报表服务器数据库中给定数据源操作的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, Microsoft::ReportingServices::Interfaces::DatasourceOperation requiredOperation);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.DatasourceOperation requiredOperation);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.DatasourceOperation -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperation As DatasourceOperation) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperation
DatasourceOperation

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。

Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperation As DatasourceOperation) As Boolean  
   Dim acl As AceCollection = DeserializeAcl(secDesc)  
   Dim ace As AceStruct  
   For Each ace In  acl  
      ' First check to see if the user or group has an access control entry for the item  
      If userName = ace.PrincipalName Then  
         ' If an entry is found, return true if the given required operation  
         ' is contained in the ACE structure.  
         Dim aclOperation As DatasourceOperation  
         For Each aclOperation In  ace.DatasourceOperations  
            If aclOperation = requiredOperation Then  
               Return True  
            End If  
         Next aclOperation  
      End If  
   Next ace  
   Return False  
End Function 'CheckAccess  
Private Function DeserializeAcl(secDesc() As Byte) As AceCollection  
   Dim bf As New BinaryFormatter()  
   Dim sdStream As New MemoryStream(secDesc)  
   Dim acl As AceCollection = CType(bf.Deserialize(sdStream), AceCollection)  
   Return acl  
End Function 'DeserializeAcl  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, DatasourceOperation requiredOperation)  
{  
   AceCollection acl = DeserializeAcl(secDesc);  
   foreach(AceStruct ace in acl)  
   {  
       // First check to see if the user or group has an access control entry for the item  
      if (userName == ace.PrincipalName)  
      {  
          // If an entry is found, return true if the given required operation  
          // is contained in the ACE structure.  
         foreach(DatasourceOperation aclOperation in ace.DatasourceOperations)  
         {  
             if (aclOperation == requiredOperation)  
                return true;  
         }  
      }  
   }  
   return false;  
}  

private AceCollection DeserializeAcl(byte[] secDesc)  
{  
   BinaryFormatter bf = new BinaryFormatter();  
   MemoryStream sdStream = new MemoryStream(secDesc);  
   AceCollection acl = (AceCollection)bf.Deserialize(sdStream);  
   return acl;  
}  

适用于

CheckAccess(String, IntPtr, Byte[], FolderOperation)

指示是否授权用户来访问报表服务器数据库中给定文件夹操作的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, Microsoft::ReportingServices::Interfaces::FolderOperation requiredOperation);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.FolderOperation requiredOperation);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.FolderOperation -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperation As FolderOperation) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperation
FolderOperation

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。

Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperation As FolderOperation) As Boolean  
   Dim acl As AceCollection = DeserializeAcl(secDesc)  
   Dim ace As AceStruct  
   For Each ace In  acl  
      ' First check to see if the user or group has an access control entry for the item  
      If userName = ace.PrincipalName Then  
         ' If an entry is found, return true if the given required operation  
         ' is contained in the ACE structure.  
         Dim aclOperation As FolderOperation  
         For Each aclOperation In  ace.FolderOperations  
            If aclOperation = requiredOperation Then  
               Return True  
            End If  
         Next aclOperation  
      End If  
   Next ace  
   Return False  
End Function 'CheckAccess  

Private Function DeserializeAcl(secDesc() As Byte) As AceCollection  
   Dim bf As New BinaryFormatter()  
   Dim sdStream As New MemoryStream(secDesc)  
   Dim acl As AceCollection = CType(bf.Deserialize(sdStream), AceCollection)  
   Return acl  
End Function 'DeserializeAcl  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, FolderOperation requiredOperation)  
{  
   AceCollection acl = DeserializeAcl(secDesc);  
   foreach(AceStruct ace in acl)  
   {  
       // First check to see if the user or group has an access control entry for the item  
      if (userName == ace.PrincipalName)  
      {  
          // If an entry is found, return true if the given required operation  
          // is contained in the ACE structure.  
         foreach(FolderOperation aclOperation in ace.FolderOperations)  
         {  
             if (aclOperation == requiredOperation)  
                return true;  
         }  
      }  
   }  
   return false;  
}  

private AceCollection DeserializeAcl(byte[] secDesc)  
{  
   BinaryFormatter bf = new BinaryFormatter();  
   MemoryStream sdStream = new MemoryStream(secDesc);  
   AceCollection acl = (AceCollection)bf.Deserialize(sdStream);  
   return acl;  
}  

适用于

CheckAccess(String, IntPtr, Byte[], FolderOperation[])

根据报表服务器数据库中某一项的操作的安全描述符,检查用户的授权凭据。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, cli::array <Microsoft::ReportingServices::Interfaces::FolderOperation> ^ requiredOperations);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.FolderOperation[] requiredOperations);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.FolderOperation[] -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperations As FolderOperation()) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperations
FolderOperation[]

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。 此示例使用重载的 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法,该方法采用单个操作作为参数。

' Overload for array of folder operations  
Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperations() As FolderOperation) As Boolean  
   Dim operation As FolderOperation  
   For Each operation In  requiredOperations  
      If Not CheckAccess(userName, userToken, secDesc, operation) Then  
         Return False  
      End If  
   Next operation  
   Return True  
End Function 'CheckAccess  
// Overload for array of folder operations  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, FolderOperation[] requiredOperations)  
{  
   foreach(FolderOperation operation in requiredOperations)  
   {  
      if (!CheckAccess(userName, userToken, secDesc, operation))  
         return false;  
   }  
   return true;   
}  

适用于

CheckAccess(String, IntPtr, Byte[], ModelItemOperation)

指示是否授权用户来访问报表服务器数据库中给定模型项操作的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, Microsoft::ReportingServices::Interfaces::ModelItemOperation requiredOperation);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.ModelItemOperation requiredOperation);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.ModelItemOperation -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperation As ModelItemOperation) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperation
ModelItemOperation

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

适用于

CheckAccess(String, IntPtr, Byte[], ModelOperation)

指示用户是否有权访问报表服务器数据库中给定模型操作的项的值。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, Microsoft::ReportingServices::Interfaces::ModelOperation requiredOperation);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.ModelOperation requiredOperation);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.ModelOperation -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperation As ModelOperation) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperation
ModelOperation

报表服务器为给定用户请求的操作。

返回

true 如果当前经过身份验证的用户根据提供的操作和安全描述符授予对项的访问权限,否则,为 false.

适用于

CheckAccess(String, IntPtr, Byte[], ReportOperation)

指示是否授权用户来访问报表服务器数据库中给定报表操作的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, Microsoft::ReportingServices::Interfaces::ReportOperation requiredOperation);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.ReportOperation requiredOperation);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.ReportOperation -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperation As ReportOperation) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperation
ReportOperation

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。

Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperation As ReportOperation) As Boolean  
   Dim acl As AceCollection = DeserializeAcl(secDesc)  
   Dim ace As AceStruct  
   For Each ace In  acl  
      ' First check to see if the user or group has an access control entry for the item  
      If userName = ace.PrincipalName Then  
         ' If an entry is found, return true if the given required operation  
         ' is contained in the ACE structure.  
         Dim aclOperation As ReportOperation  
         For Each aclOperation In  ace.ReportOperations  
            If aclOperation = requiredOperation Then  
               Return True  
            End If  
         Next aclOperation  
      End If  
   Next ace  
   Return False  
End Function 'CheckAccess  

Private Function DeserializeAcl(secDesc() As Byte) As AceCollection  
   Dim bf As New BinaryFormatter()  
   Dim sdStream As New MemoryStream(secDesc)  
   Dim acl As AceCollection = CType(bf.Deserialize(sdStream), AceCollection)  
   Return acl  
End Function 'DeserializeAcl  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, ReportOperation requiredOperation)  
{  
   AceCollection acl = DeserializeAcl(secDesc);  
   foreach(AceStruct ace in acl)  
   {  
       // First check to see if the user or group has an access control entry for the item  
      if (userName == ace.PrincipalName)  
      {  
          // If an entry is found, return true if the given required operation  
          // is contained in the ACE structure.  
         foreach(ReportOperation aclOperation in ace.ReportOperations)  
         {  
             if (aclOperation == requiredOperation)  
                return true;  
         }  
      }  
   }  
   return false;  
}  

private AceCollection DeserializeAcl(byte[] secDesc)  
{  
   BinaryFormatter bf = new BinaryFormatter();  
   MemoryStream sdStream = new MemoryStream(secDesc);  
   AceCollection acl = (AceCollection)bf.Deserialize(sdStream);  
   return acl;  
}  

适用于

CheckAccess(String, IntPtr, Byte[], ResourceOperation)

指示是否授权用户来访问报表服务器数据库中给定资源操作的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, Microsoft::ReportingServices::Interfaces::ResourceOperation requiredOperation);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.ResourceOperation requiredOperation);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.ResourceOperation -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperation As ResourceOperation) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperation
ResourceOperation

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。

Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperation As ResourceOperation) As Boolean  
   Dim acl As AceCollection = DeserializeAcl(secDesc)  
   Dim ace As AceStruct  
   For Each ace In  acl  
      ' First check to see if the user or group has an access control entry for the item  
      If userName = ace.PrincipalName Then  
         ' If an entry is found, return true if the given required operation  
         ' is contained in the ACE structure.  
         Dim aclOperation As ResourceOperation  
         For Each aclOperation In  ace.ResourceOperations  
            If aclOperation = requiredOperation Then  
               Return True  
            End If  
         Next aclOperation  
      End If  
   Next ace  
   Return False  
End Function 'CheckAccess  

Private Function DeserializeAcl(secDesc() As Byte) As AceCollection  
   Dim bf As New BinaryFormatter()  
   Dim sdStream As New MemoryStream(secDesc)  
   Dim acl As AceCollection = CType(bf.Deserialize(sdStream), AceCollection)  
   Return acl  
End Function 'DeserializeAcl  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, ResourceOperation requiredOperation)  
{  
   AceCollection acl = DeserializeAcl(secDesc);  
   foreach(AceStruct ace in acl)  
   {  
       // First check to see if the user or group has an access control entry for the item  
      if (userName == ace.PrincipalName)  
      {  
          // If an entry is found, return true if the given required operation  
          // is contained in the ACE structure.  
         foreach(ResourceOperation aclOperation in ace.ResourceOperations)  
         {  
             if (aclOperation == requiredOperation)  
                return true;  
         }  
      }  
   }  
   return false;  
}  

private AceCollection DeserializeAcl(byte[] secDesc)  
{  
   BinaryFormatter bf = new BinaryFormatter();  
   MemoryStream sdStream = new MemoryStream(secDesc);  
   AceCollection acl = (AceCollection)bf.Deserialize(sdStream);  
   return acl;  
}  

适用于

CheckAccess(String, IntPtr, Byte[], ResourceOperation[])

指示是否授权用户来访问报表服务器数据库中给定资源操作数组的项。

public:
 bool CheckAccess(System::String ^ userName, IntPtr userToken, cli::array <System::Byte> ^ secDesc, cli::array <Microsoft::ReportingServices::Interfaces::ResourceOperation> ^ requiredOperations);
public bool CheckAccess (string userName, IntPtr userToken, byte[] secDesc, Microsoft.ReportingServices.Interfaces.ResourceOperation[] requiredOperations);
abstract member CheckAccess : string * nativeint * byte[] * Microsoft.ReportingServices.Interfaces.ResourceOperation[] -> bool
Public Function CheckAccess (userName As String, userToken As IntPtr, secDesc As Byte(), requiredOperations As ResourceOperation()) As Boolean

参数

userName
String

请求访问报表服务器的用户的名称。

userToken
IntPtr

nativeint

用户帐户标记。 此标记主要由报表服务器用于处理 Microsoft Windows 帐户,以便支持针对 Windows 身份验证的凭据管理。

secDesc
Byte[]

项的安全描述符。

requiredOperations
ResourceOperation[]

报表服务器为给定用户请求的操作。

返回

如果授权当前验证了身份的用户基于提供的操作和安全描述符访问该项,则返回 true

示例

以下示例代码使用 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法根据报表服务器数据库中项的安全描述符评估用户的授权凭据。 此示例使用重载的 [CheckAccess 方法 (String、 IntPtr、 Byte<xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> 方法,该方法采用单个操作作为参数。

' Overload for array of resource operations  
Public Function CheckAccess(userName As String, userToken As IntPtr, secDesc() As Byte, requiredOperations() As ResourceOperation) As Boolean  
   Dim operation As ResourceOperation  
   For Each operation In  requiredOperations  
      If Not CheckAccess(userName, userToken, secDesc, operation) Then  
         Return False  
      End If  
   Next operation  
   Return True  
End Function 'CheckAccess  
// Overload for array of resource operations  
public bool CheckAccess(string userName, IntPtr userToken, byte[] secDesc, ResourceOperation[] requiredOperations)  
{  
   foreach(ResourceOperation operation in requiredOperations)  
   {  
      if (!CheckAccess(userName, userToken, secDesc, operation))  
         return false;  
   }  
   return true;   
}  

适用于