I'm working on a SSAS project in which I, amongst other things, need to get a complete list of users for a tabular cube, in C#. Currently I have it working in such a way that I can get the roles, but the data is incomplete. When I call the Server.Database.Roles (simplified for readability) property and enumerate through it I only get ID, Name and CreatedTimeStamp. What I am missing, which is crucial, is Members, CellPermissions (DAX Filters) and the permissions for those members. The permissions (read/write/administrator) I am currently looking for in Server.Database.Cube but the CubePermissions are empty...
In SSMS when I script one of my testroles the role contains:
<ID>Role</ID>
<Name>TestRole</Name>
<Description>role for testing</Description>
<Members>
<Member>
<Name>THORVALDDATA\rj</Name>
<Sid>OMITTED</Sid>
</Member>
<Member>
<Name>THORVALDDATA\dp</Name>
<Sid>OMITTED</Sid>
</Member>
<Member>
<Name>THORVALDDATA\jtl</Name>
<Sid>OMITTED</Sid>
</Member>
</Members>
But as said earlier, when I enumerate it in code, I don't get members and description.
Can any of you clever people help me figure out what is going wrong here?
All my code:
RoleCollection roleCollection = _analysisServer.Databases[dbID].Roles;
Database database = _analysisServer.Databases[dbID];
Dictionary<string, CubeRole> roles = new Dictionary<string, CubeRole>();
foreach (Role role in roleCollection)
{
CubeRole cRole = new CubeRole();
cRole.ID = role.ID;
cRole.Name = role.Name;
cRole.Members = role.Members;
CubeCollection cubeCollection = _analysisServer.Databases[dbID].Cubes;
foreach (Cube cube in cubeCollection)
{
foreach (CubePermission cubePermission in cube.CubePermissions)
{
cRole.Filters = cubePermission.CellPermissions;
cRole.Permission.Add(cubePermission);
}
}
roles.Add(cRole.Name, cRole);
}
return roles;