Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Clampazzo
Resolver I
Resolver I

Can I add a role for RLS Using XMLA Endpiont and C#?

I have managed to create a new semantic model using XMLA Endpoint and C# but now I need to be able to create Roles for RLS using the same method.  Is this allowed?  And if so How can I go about doing it? 

Below is my simple code in creating the semantic model.

 

If I can call a REST API tha twould work too... I just didn't see any that would work.

 

 

   string newDatabaseName = server.Databases.GetNewName(DatabaseName);

   var database = new Microsoft.AnalysisServices.Database()
   {
       Name = newDatabaseName,
       ID = newDatabaseName,
       CompatibilityLevel = 1520,
       StorageEngineUsed = Microsoft.AnalysisServices.StorageEngineUsed.TabularMetadata,
       Model = new Model()
       {
           Name = DatabaseName + "-Model",
           Description = "A Demo Tabular data model with 1520 compatibility level."
       }
   };

   server.Databases.Add(database);
   database.Update(Microsoft.AnalysisServices.UpdateOptions.ExpandFull);

 

1 ACCEPTED SOLUTION

Hi @Clampazzo 

 

You could use SSMS to log into the XMLA end point and then script out the database?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

6 REPLIES 6
GilbertQ
Super User
Super User

Hi @Clampazzo 

 

What I would do is to connect to the XMLA endpoint using tablet editor and create the roles using tabler editor. It would be a lot quicker and efficiently create your role and give them as working as expected.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Thanks for the reply @GilbertQ , while that would be easy to do I need to dynamically create these datasets.  They will all be DirectQuery but I am creating a new dataset (sometimes multiple) per client workspace.  So going in manually later would be difficult to do.  

If there's a way to copy a template dataset and then modify it using xmla (while keeping roles) that would be acceptable too.

Hi @Clampazzo 

 

One option might be to script after the database after you have created the roles. You can then use this script to reapply to other app workspaces with the roles as part of the script.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

That sounds like a possibl workaround... is there any documentation on how to do that?

Hi @Clampazzo 

 

You could use SSMS to log into the XMLA end point and then script out the database?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

I'm accepting as solution but I may ping back if I have more questions.  Thanks for your help.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.