IAuthorizationExtension.CheckAccess Metodo

Definizione

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata.

Overload

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione di catalogo specificata.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una matrice di cataloghi.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su un'origine dati.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una cartella.

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

Verifica le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per l'esecuzione di operazioni su un elemento nel database del server di report.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su un elemento di un modello.

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

Indica un valore se un utente è autorizzato ad accedere a un elemento nel database del server di report per un'operazione del modello specificata.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione di report specificata.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una risorsa.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una matrice di risorse.

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione di catalogo specificata.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperation
CatalogOperation

Operazione richiesta dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report.

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

Si applica a

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una matrice di cataloghi.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperations
CatalogOperation[]

Operazioni richieste dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report. Nell'esempio viene usato il metodo di overload [CheckAccess (String, IntPtr, byte <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> Method che accetta una singola operazione come argomento.

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

Si applica a

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su un'origine dati.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperation
DatasourceOperation

Operazione richiesta dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report.

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

Si applica a

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una cartella.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperation
FolderOperation

Operazione richiesta dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report.

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

Si applica a

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

Verifica le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per l'esecuzione di operazioni su un elemento nel database del server di report.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperations
FolderOperation[]

Operazioni richieste dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report. Nell'esempio viene usato il metodo di overload [CheckAccess (String, IntPtr, byte <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> Method che accetta una singola operazione come argomento.

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

Si applica a

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su un elemento di un modello.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperation
ModelItemOperation

Operazioni richieste dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Si applica a

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

Indica un valore se un utente è autorizzato ad accedere a un elemento nel database del server di report per un'operazione del modello specificata.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperation
ModelOperation

Operazioni richieste dal server di report per un determinato utente.

Restituisce

Boolean

true Se all'utente attualmente autenticato viene concesso l'accesso all'elemento in base all'operazione e al descrittore di sicurezza forniti. in caso contrario, false .

Si applica a

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione di report specificata.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperation
ReportOperation

Operazione richiesta dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report.

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

Si applica a

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una risorsa.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperation
ResourceOperation

Operazione richiesta dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report.

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

Si applica a

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

Indica se un utente è autorizzato o meno ad accedere a un elemento nel database del server di report per eseguire un'operazione specificata su una matrice di risorse.

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

Parametri

userName
String

Nome dell'utente che ha richiesto l'accesso al server di report.

userToken
IntPtr

Token dell'account utente. Il token viene principalmente utilizzato dal server di report come handle di un account Microsoft Windows per supportare la gestione delle credenziali per l'autenticazione di Windows.

secDesc
Byte[]

Descrittore di sicurezza dell'elemento.

requiredOperations
ResourceOperation[]

Operazioni richieste dal server di report per un determinato utente.

Restituisce

Boolean

Restituisce true se all'utente attualmente autorizzato viene concesso accesso all'elemento in base all'operazione specificata e al descrittore di sicurezza.

Esempio

Nell'esempio di codice seguente viene utilizzato il metodo [CheckAccess (String, IntPtr, byte) <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> per valutare le credenziali di autorizzazione di un utente rispetto a un descrittore di sicurezza per un elemento nel database del server di report. Nell'esempio viene usato il metodo di overload [CheckAccess (String, IntPtr, byte <xref:Microsoft.ReportingServices.Interfaces.IAuthorizationExtension.CheckAccess%2A> Method che accetta una singola operazione come argomento.

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

Si applica a