次の方法で共有


CheckAccess メソッド (String, IntPtr, Byte[], CatalogOperation)

特定のカタログ操作に関して、レポート サーバー データベースのアイテムへのアクセスをユーザーに承認するかどうかを示します。

名前空間:  Microsoft.ReportingServices.Interfaces
アセンブリ:   Microsoft.ReportingServices.SharePoint.UI.WebParts (Microsoft.ReportingServices.SharePoint.UI.WebParts.dll)
  Microsoft.ReportingServices.Interfaces (Microsoft.ReportingServices.Interfaces.dll)

構文

'宣言
<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey := "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")> _
Function CheckAccess ( _
    userName As String, _
    userToken As IntPtr, _
    secDesc As Byte(), _
    requiredOperation As CatalogOperation _
) As Boolean
'使用
Dim instance As IAuthorizationExtension
Dim userName As String
Dim userToken As IntPtr
Dim secDesc As Byte()
Dim requiredOperation As CatalogOperation
Dim returnValue As Boolean

returnValue = instance.CheckAccess(userName, _
    userToken, secDesc, requiredOperation)
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
bool CheckAccess(
    string userName,
    IntPtr userToken,
    byte[] secDesc,
    CatalogOperation requiredOperation
)
[StrongNameIdentityPermissionAttribute(SecurityAction::LinkDemand, PublicKey = L"0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
bool CheckAccess(
    String^ userName, 
    IntPtr userToken, 
    array<unsigned char>^ secDesc, 
    CatalogOperation requiredOperation
)
[<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")>]
abstract CheckAccess : 
        userName:string * 
        userToken:IntPtr * 
        secDesc:byte[] * 
        requiredOperation:CatalogOperation -> bool 
function CheckAccess(
    userName : String, 
    userToken : IntPtr, 
    secDesc : byte[], 
    requiredOperation : CatalogOperation
) : boolean

パラメーター

  • userName
    型: System. . :: . .String
    レポート サーバーへのアクセスを要求しているユーザーの名前です。
  • userToken
    型: System. . :: . .IntPtr
    ユーザー アカウント トークンです。このトークンは、Windows 認証の資格情報管理をサポートする Microsoft Windows アカウントのハンドルとして、主にレポート サーバーによって使用されます。
  • secDesc
    型: array<System. . :: . .Byte> [] () [] []
    アイテムのセキュリティ記述子です。

戻り値

型: System. . :: . .Boolean
現在認証されているユーザーに、指定された操作およびセキュリティ記述子に基づいてアイテムへのアクセスが許可された場合、true を返します。

使用例

次のサンプル コードでは、CheckAccess メソッドを使用して、レポート サーバー データベースのアイテムのセキュリティ記述子に対してユーザーの承認資格情報を評価します。

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