In authorization, the key to any custom security implementation is the access check, which is implemented in the CheckAccess method. CheckAccess is called each time a user attempts an operation on the report server. The CheckAccess method is overloaded for each operation type. For folder operations, an example of an access check might look like the following:
// Overload for Folder operations
public bool CheckAccess(
string userName,
IntPtr userToken,
byte[] secDesc,
FolderOperation requiredOperation)
{
// If the user is the administrator, allow unrestricted access.
if (userName == m_adminUserName)
return true;
AceCollection acl = DeserializeAcl(secDesc);
foreach(AceStruct ace in acl)
{
if (userName == ace.PrincipalName)
{
foreach(FolderOperation aclOperation in
ace.FolderOperations)
{
if (aclOperation == requiredOperation)
return true;
}
}
}
return false;
}
The report server calls the CheckAccess method by passing in the name of the logged-on user, a user token, the security descriptor for the item, and the requested operation. Here you would check the security descriptor for the user name and the appropriate permission to complete the request, then return true to signify that access is granted or false to signify access is denied.