Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

IAuthorizationExtension.GetPermissions Method

Returns the set of permissions granted a specific user for an item in the report server database.

Namespace:  Microsoft.ReportingServices.Interfaces
Assemblies:   Microsoft.ReportingServices.SharePoint.UI.WebParts (in Microsoft.ReportingServices.SharePoint.UI.WebParts.dll)
  Microsoft.ReportingServices.Interfaces (in Microsoft.ReportingServices.Interfaces.dll)
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
StringCollection GetPermissions(
	string userName,
	IntPtr userToken,
	SecurityItemType itemType,
	byte[] secDesc
)

Parameters

userName
Type: System.String
The name of the user as returned by the GetUserInfo method of IAuthenticationExtension.
userToken
Type: System.IntPtr
A pointer to the user ID returned by the GetUserInfo method.
itemType
Type: Microsoft.ReportingServices.Interfaces.SecurityItemType
The type of item in the report server database for which the permissions are returned.
secDesc
Type: System.Byte[]
The security descriptor associated with the item.

Return Value

Type: System.Collections.Specialized.StringCollection
A StringCollection that contains the name of each permission associated with the user for a given item.

The return value of this method provides underlying support for the Web service GetPermissions method.

The following example uses the Microsoft.SqlServer.ReportingServices.ReportingService.GetPermissions method to evaluate the access code list for an item in the report server database with regards to a specific user's authorization credentials. You use this method to provide a set of permissions that are returned by the Web service GetPermissions method.

private static Hashtable m_CatOperNames;
private static Hashtable m_FldOperNames;
private static Hashtable m_RptOperNames;
private static Hashtable m_ResOperNames;
private static Hashtable m_DSOperNames;

private const int NrRptOperations = 27;
private const int NrFldOperations = 9;
private const int NrResOperations = 7; 
private const int NrDSOperations = 7;
private const int NrCatOperations = 15;

private static void InitializeMaps()
{

   // create operation names data
   m_CatOperNames = new Hashtable();
   m_CatOperNames.Add(CatalogOperation.CreateRoles,                   OperationNames.OperCreateRoles);
   m_CatOperNames.Add(CatalogOperation.DeleteRoles,                   OperationNames.OperDeleteRoles);
   m_CatOperNames.Add(CatalogOperation.ReadRoleProperties,            OperationNames.OperReadRoleProperties);
   m_CatOperNames.Add(CatalogOperation.UpdateRoleProperties,          OperationNames.OperUpdateRoleProperties);
   m_CatOperNames.Add(CatalogOperation.ReadSystemProperties,          OperationNames.OperReadSystemProperties);
   m_CatOperNames.Add(CatalogOperation.UpdateSystemProperties,        OperationNames.OperUpdateSystemProperties);
   m_CatOperNames.Add(CatalogOperation.GenerateEvents,                OperationNames.OperGenerateEvents);
   m_CatOperNames.Add(CatalogOperation.ReadSystemSecurityPolicy,      OperationNames.OperReadSystemSecurityPolicy);
   m_CatOperNames.Add(CatalogOperation.UpdateSystemSecurityPolicy,    OperationNames.OperUpdateSystemSecurityPolicy);
   m_CatOperNames.Add(CatalogOperation.CreateSchedules,               OperationNames.OperCreateSchedules);
   m_CatOperNames.Add(CatalogOperation.DeleteSchedules,               OperationNames.OperDeleteSchedules);
   m_CatOperNames.Add(CatalogOperation.ReadSchedules,                 OperationNames.OperReadSchedules);
   m_CatOperNames.Add(CatalogOperation.UpdateSchedules,               OperationNames.OperUpdateSchedules);
   m_CatOperNames.Add(CatalogOperation.ListJobs,                      OperationNames.OperListJobs);
   m_CatOperNames.Add(CatalogOperation.CancelJobs,                    OperationNames.OperCancelJobs);
   if (m_CatOperNames.Count != NrCatOperations)
   {
      throw new Exception("Number of catalog names don't match.");
   }

   m_FldOperNames = new Hashtable();
   m_FldOperNames.Add(FolderOperation.CreateFolder,                  OperationNames.OperCreateFolder);
   m_FldOperNames.Add(FolderOperation.Delete,                        OperationNames.OperDelete);
   m_FldOperNames.Add(FolderOperation.ReadProperties,                OperationNames.OperReadProperties);
   m_FldOperNames.Add(FolderOperation.UpdateProperties,              OperationNames.OperUpdateProperties);
   m_FldOperNames.Add(FolderOperation.CreateReport,                  OperationNames.OperCreateReport);
   m_FldOperNames.Add(FolderOperation.CreateResource,                OperationNames.OperCreateResource);
   m_FldOperNames.Add(FolderOperation.ReadAuthorizationPolicy,       OperationNames.OperReadAuthorizationPolicy);
   m_FldOperNames.Add(FolderOperation.UpdateDeleteAuthorizationPolicy,OperationNames.OperUpdateDeleteAuthorizationPolicy);
   m_FldOperNames.Add(FolderOperation.CreateDatasource,              OperationNames.OperCreateDatasource);
   if (m_FldOperNames.Count != NrFldOperations)
   {
       throw new Exception("Number of folder names don't match.");
   }


   m_RptOperNames = new Hashtable();
   m_RptOperNames.Add(ReportOperation.Delete,                        OperationNames.OperDelete);
   m_RptOperNames.Add(ReportOperation.ReadProperties,                OperationNames.OperReadProperties);
   m_RptOperNames.Add(ReportOperation.UpdateProperties,              OperationNames.OperUpdateProperties);
   m_RptOperNames.Add(ReportOperation.UpdateParameters,              OperationNames.OperUpdateParameters);
   m_RptOperNames.Add(ReportOperation.ReadDatasource,                OperationNames.OperReadDatasources);
   m_RptOperNames.Add(ReportOperation.UpdateDatasource,              OperationNames.OperUpdateDatasources);
   m_RptOperNames.Add(ReportOperation.ReadReportDefinition,          OperationNames.OperReadReportDefinition);
   m_RptOperNames.Add(ReportOperation.UpdateReportDefinition,        OperationNames.OperUpdateReportDefinition);
   m_RptOperNames.Add(ReportOperation.CreateSubscription,            OperationNames.OperCreateSubscription);
   m_RptOperNames.Add(ReportOperation.DeleteSubscription,            OperationNames.OperDeleteSubscription);
   m_RptOperNames.Add(ReportOperation.ReadSubscription,              OperationNames.OperReadSubscription);
   m_RptOperNames.Add(ReportOperation.UpdateSubscription,            OperationNames.OperUpdateSubscription);
   m_RptOperNames.Add(ReportOperation.CreateAnySubscription,         OperationNames.OperCreateAnySubscription);
   m_RptOperNames.Add(ReportOperation.DeleteAnySubscription,         OperationNames.OperDeleteAnySubscription);
   m_RptOperNames.Add(ReportOperation.ReadAnySubscription,           OperationNames.OperReadAnySubscription);
   m_RptOperNames.Add(ReportOperation.UpdateAnySubscription,         OperationNames.OperUpdateAnySubscription);
   m_RptOperNames.Add(ReportOperation.UpdatePolicy,                  OperationNames.OperUpdatePolicy);
   m_RptOperNames.Add(ReportOperation.ReadPolicy,                    OperationNames.OperReadPolicy);
   m_RptOperNames.Add(ReportOperation.DeleteHistory,                 OperationNames.OperDeleteHistory);
   m_RptOperNames.Add(ReportOperation.ListHistory,                   OperationNames.OperListHistory);
   m_RptOperNames.Add(ReportOperation.ExecuteAndView,                OperationNames.OperExecuteAndView);
   m_RptOperNames.Add(ReportOperation.CreateResource,                OperationNames.OperCreateResource);
   m_RptOperNames.Add(ReportOperation.CreateSnapshot,                OperationNames.OperCreateSnapshot);
   m_RptOperNames.Add(ReportOperation.ReadAuthorizationPolicy,       OperationNames.OperReadAuthorizationPolicy);
   m_RptOperNames.Add(ReportOperation.UpdateDeleteAuthorizationPolicy,OperationNames.OperUpdateDeleteAuthorizationPolicy);
   m_RptOperNames.Add(ReportOperation.Execute,                       OperationNames.OperExecute);
   m_RptOperNames.Add(ReportOperation.CreateLink,                    OperationNames.OperCreateLink);
   if (m_RptOperNames.Count != NrRptOperations)
   {
      throw new Exception("Number of report names don't match.");
   }
   m_ResOperNames = new Hashtable();
   m_ResOperNames.Add(ResourceOperation.Delete,                            OperationNames.OperDelete);
   m_ResOperNames.Add(ResourceOperation.ReadProperties,                    OperationNames.OperReadProperties);
   m_ResOperNames.Add(ResourceOperation.UpdateProperties,                  OperationNames.OperUpdateProperties);
   m_ResOperNames.Add(ResourceOperation.ReadContent,                       OperationNames.OperReadContent);
   m_ResOperNames.Add(ResourceOperation.UpdateContent,                     OperationNames.OperUpdateContent);
   m_ResOperNames.Add(ResourceOperation.ReadAuthorizationPolicy,           OperationNames.OperReadAuthorizationPolicy);
   m_ResOperNames.Add(ResourceOperation.UpdateDeleteAuthorizationPolicy,   OperationNames.OperUpdateDeleteAuthorizationPolicy);
   if (m_ResOperNames.Count != NrResOperations)
   {
      throw new Exception("Number of resource names don't match.");
   }

   m_DSOperNames = new Hashtable();
   m_DSOperNames.Add(DatasourceOperation.Delete,                            OperationNames.OperDelete);
   m_DSOperNames.Add(DatasourceOperation.ReadProperties,                    OperationNames.OperReadProperties);
   m_DSOperNames.Add(DatasourceOperation.UpdateProperties,                  OperationNames.OperUpdateProperties);
   m_DSOperNames.Add(DatasourceOperation.ReadContent,                       OperationNames.OperReadContent);
   m_DSOperNames.Add(DatasourceOperation.UpdateContent,                     OperationNames.OperUpdateContent);
   m_DSOperNames.Add(DatasourceOperation.ReadAuthorizationPolicy,           OperationNames.OperReadAuthorizationPolicy);
   m_DSOperNames.Add(DatasourceOperation.UpdateDeleteAuthorizationPolicy,   OperationNames.OperUpdateDeleteAuthorizationPolicy);
   if (m_DSOperNames.Count != NrDSOperations)
   {
      throw new Exception("Number of datasource names don't match.");
   }
}

public StringCollection GetPermissions(string userName, IntPtr userToken, SecurityItemType itemType, byte[] secDesc)
{
   StringCollection permissions = new StringCollection();
   AceCollection acl = DeserializeAcl(secDesc);
   foreach(AceStruct ace in acl)
   {
      if (userName == ace.PrincipalName)
      {
         foreach(CatalogOperation aclOperation in ace.CatalogOperations)
         {
            if (!permissions.Contains((string)m_CatOperNames[aclOperation]))
               permissions.Add((string)m_CatOperNames[aclOperation]);
         }
         foreach(ReportOperation aclOperation in ace.ReportOperations)
         {
            if (!permissions.Contains((string)m_RptOperNames[aclOperation]))
               permissions.Add((string)m_RptOperNames[aclOperation]);
         }
         foreach(FolderOperation aclOperation in ace.FolderOperations)
         {
            if (!permissions.Contains((string)m_FldOperNames[aclOperation]))
               permissions.Add((string)m_FldOperNames[aclOperation]);
         }
         foreach(ResourceOperation aclOperation in ace.ResourceOperations)
         {
            if (!permissions.Contains((string)m_ResOperNames[aclOperation]))
               permissions.Add((string)m_ResOperNames[aclOperation]);
         }
         foreach(DatasourceOperation aclOperation in ace.DatasourceOperations)
         {
            if (!permissions.Contains((string)m_DSOperNames[aclOperation]))
               permissions.Add((string)m_DSOperNames[aclOperation]);
         }
      }
   }
   return permissions;

}

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.