IAuthorizationExtension.CheckAccess Method (String, IntPtr, Byte[], ReportOperation)

Indicates whether a user is authorized to access an item in the report server database for a given report operation. This method is not CLS-compliant.

命名空间: Microsoft.ReportingServices.Interfaces
程序集: Microsoft.ReportingServices.Interfaces (in microsoft.reportingservices.interfaces.dll)

语法

声明
<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey:="0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")> _
Function CheckAccess ( _
    userName As String, _
    userToken As IntPtr, _
    secDesc As Byte(), _
    requiredOperation As ReportOperation _
) As Boolean
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey="0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")] 
bool CheckAccess (
    string userName,
    IntPtr userToken,
    byte[] secDesc,
    ReportOperation requiredOperation
)
[StrongNameIdentityPermissionAttribute(SecurityAction::LinkDemand, PublicKey=L"0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")] 
bool CheckAccess (
    String^ userName, 
    IntPtr userToken, 
    array<unsigned char>^ secDesc, 
    ReportOperation requiredOperation
)
/** @attribute StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey="0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8") */ 
boolean CheckAccess (
    String userName, 
    IntPtr userToken, 
    byte[] secDesc, 
    ReportOperation requiredOperation
)
function CheckAccess (
    userName : String, 
    userToken : IntPtr, 
    secDesc : byte[], 
    requiredOperation : ReportOperation
) : boolean

参数

  • userName
    The name of the user requesting access to the report server.
  • userToken
    A user account token. This token is primarily used by the report server as a handle to a Microsoft Windows account in support of credential management for Windows authentication.
  • secDesc
    The security descriptor for the item.
  • requiredOperation
    The operation being requested by the report server for a given user.

返回值

Returns true if the currently authenticated user is granted access to the item based on the supplied operation and security descriptor.

示例

The following example code uses the CheckAccess method to evaluate a user's authorization credentials against a security descriptor for an item in the report server database.

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;
}

线程安全

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

平台

开发平台

有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。

目标平台

有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。

请参阅

参考

IAuthorizationExtension Interface
IAuthorizationExtension Members
Microsoft.ReportingServices.Interfaces Namespace