C# amo get roles complete

雨燕双飞 提交于 2019-12-02 09:40:41

With tabular you can have administrators at the server level. And at the database level you have just 3 built-in permissions: 1) Full Control 2) Process Database & 3) Read. Each role you create in a database can have a selection of these permissions. There are no cubes in tabular so you just have the 2 levels, server & database. MSDN is a good starting point for understanding permissions & roles in tabular https://msdn.microsoft.com/en-us/library/hh213165.aspx

You can loop through the roles of a database to pull out the role member in each and the permissions associated with each role:

   //loop through database permissions
   foreach (AMO.DatabasePermission dbp in Analysisdb.DatabasePermissions)
          {
           Console.Write(dbp.Role.Name); //role name
           Console.Write(dbp.Read); // Is read role?
           Console.Write(dbp.Process); // Is process role?
           Console.Write(dbp.Administer); // Is Full control role?
          //loop through database permissions role members
          foreach (AMO.RoleMember rolemember in dbp.Role.Members)
              { 
              Console.Write(rolemember.Name); 
               }
          }

The DAX expressions for each dimension can be pulled out by looping through every dimension for every role. This example below will get the DAX expression for the Currency dimension for the Users role in the codeplex AdventureWorks sample model:

     using (AMO.DimensionPermission dimensionPermission = AnalysisDb.Dimensions.GetByName("Currency").DimensionPermissions[0]);
Console.Write(dimensionPermission.AllowedRowsExpression);

See http://tabularamo2012.codeplex.com/SourceControl/latest#AMO2TabularV2/AMO2Tabular.RlsFunctions.cs for more on tabular AMO.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!