web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Security Roles - Record Level Privileges Data OData Feed

(0) ShareShare
ReportReport
Posted on by

Hi,

My goal is to be able to get the data that shows what Security Roles have what privileges. Specifically, I am looking to get the data of record-level privileges for each security role. I am hoping to pull this data through the API (Odata Feed) so I can display in a Power BI report. I was able to find how users are related to security roles but I can not find out how Security Roles are related to their privileges specifically the record level privileges. Has anyone been able to do this before?

Any help is appreciated thank you!

I have the same question (0)
  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi grant.culp,

    You can obtain this information with the Export Security Role tool in the XrmToolBox.

  • Community Member Profile Picture
    on at

    Thank you for your reply! Do you know if this information is available through the API to read in? I want to build something that updates consistently with the changes.

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi grant,club,

    The RetrieveRolePrivilegesRole Function is what you are looking for.

    var eachRolePrivileges = [];
    var roles = Xrm.Utility.getGlobalContext().userSettings.securityRoles;
    roles.forEach(function(item, i) {
      eachRolePrivileges[i] = retrieveRolePrivileges(item);
    });
    retrieveRolePrivileges(roleId);
    function retrieveRolePrivileges(roleId) {
      var url = Xrm.Page.context.getClientUrl();
      var req = new XMLHttpRequest();
      req.open(
        "GET",
        url   "/api/data/v9.1/RetrieveRolePrivilegesRole(RoleId=" roleId ")",
        false
      );
      req.setRequestHeader("OData-MaxVersion", "4.0");
      req.setRequestHeader("OData-Version", "4.0");
      req.setRequestHeader("Accept", "application/json");
      req.setRequestHeader("Prefer", 'odata.include-annotations="*"');
      req.send();
        if (req.readyState === 4) {
          if (req.status === 200) {
            var results = JSON.parse(req.response);
            return results.RolePrivileges;
          } else {
              console.log('err');
          }
        }
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 96 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans