Tuesday, March 20, 2012

Retrieving info from ReportServer tables

Hi,
If I was to query the ReportServer database, can I retrieve info that would
tell me what directories or reports a Group/User has access to? If so, what
tables should I retrieve the data?
Thanks!You need to use the GetPolicies and SetPolicies methods on the web service.
You don't want to do anything directly to the database.
Here's a code snippet giving you an idea of how to use these methods:
private bool AddUserToFolderPolicy(string folder, string user, ref string
errMessage)
{
try
{
//Get the Browser role
Role[]roles = m_ReportingService.ListRoles();
Role browserRole = new Role();
foreach (Role r in roles)
{
if (r.Name == "Browser") browserRole = r;
break;
}
Role[] policyRoles = new Role[1];
policyRoles[0] = new Role();
policyRoles[0] =browserRole;
//Get the current policies of the folder in question
string path = "/" + folder;
bool inheritParent = false;
Policy[] currentPolicies = m_ReportingService.GetPolicies(path, out
inheritParent);
//If the user is currently in the current policy set just return
for(int i=0;i<currentPolicies.Length;i++)
if(currentPolicies[i].GroupUserName == user)
return true;
//Create the new policy array and add the new user
ArrayList arrPolicies = new ArrayList(currentPolicies);
Policy p = new Policy();
p.GroupUserName = user;
p.Roles = policyRoles;
arrPolicies.Add(p);
Policy[] finalPolicies = (Policy[])arrPolicies.ToArray(typeof(Policy));
//Set the policies
m_ReportingService.SetPolicies(path,finalPolicies);
}
catch (Exception e)
{
errMessage = e.Message;
return false;
}
return true;
}
Adrian M.
MCP
"clutch" <clutch@.discussions.microsoft.com> wrote in message
news:243F3E14-536F-4438-AAFC-36A814725AFA@.microsoft.com...
> Hi,
> If I was to query the ReportServer database, can I retrieve info that
> would
> tell me what directories or reports a Group/User has access to? If so,
> what
> tables should I retrieve the data?
> Thanks!
>

No comments:

Post a Comment