Wednesday, March 28, 2012

How to assign roles to a user on reporting server through Web Service MEthod

I am using the Web service of SSRS to assign the roles for a user that exists on that reporting server machine.

I am using the followng code to do this.

Policy[] p = new Policy[1];
p[0] = new Policy();
Role[] R = new Role[1];
R[0]= new Role();
R[0].Name = "Content Manager";
p[0].GroupUserName = "systemtest\user1";
rs.SetPolicies(@."/",p);

The same I have tried with SetSystemPolicy method also.

Policy[] p = new Policy[1];
p[0] = new Policy();
Role[] R = new Role[1];
R[0]= new Role();
R[0].Name = "Content Manager";
p[0].GroupUserName = "systemtest\user1";
rs.SetSystemPolicies(p);

I have used the above codes in achieving the mapping between the SSRS role and the windows local user. Getting error on this.

Vikas

The code looks good to me. What kind of error did you get? There might be a couple of reasons for failing:

1. you do not have permission to perform this action

2. Role can be managed by user, "Content Manager" is a pre-defined role out of box. But it may have been deleted. You have to make sure the role exists. ListRoles soap APIs can get you the available roles.

3. There is already a policy associated with the same user.

...

|||

There is only one issue i see...

p[0].Roles = R;

Before calling SetPolicies.

No comments:

Post a Comment