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 :
Microsoft Dynamics CRM (Archived)

Exporting role permissions data to excel

(1) ShareShare
ReportReport
Posted on by

Hi

Is there anyway I can export all the permissions data for a specific role to excel or word or pdf for analysis purpose.

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    If you have CRM OnPremise, you can use a SQL query to get this information, but if you have CRM Online the only way to get this is to use API calls.

    The following SQL queries should give most of what you want (though note that they were written before Access Teams were available, so may not be complete). You'll need appropriate SQL permissions to run these, as some of the data is not accessible through filtered views

    -- Simple query on entity roles
    select r.name as RoleName, r.businessunitidname as BusinessUnitName
    , e.Name as EntityName, p.AccessRight, rp.PrivilegeDepthMask
    from dbo.FilteredRole r
    join dbo.RolePrivileges rp on r.roleid = rp.roleid
    join dbo.FilteredPrivilege p on rp.privilegeid = p.privilegeid
    join dbo.PrivilegeObjectTypeCodes potc on p.privilegeid = potc.privilegeid
    join MetadataSchema.Entity e on potc.ObjectTypeCode = e.ObjectTypeCode
    
    -- Query on entity roles, consolidating records
    select RoleName, BusinessUnitName, EntityName
    , max([Read]) as [Read], max([Write]) as [Write], max([Append]) as [Append], max([AppendTo]) as [AppendTo]
    , max([Create]) as [Create], max([Delete]) as [Delete], max([Share]) as [Share], max([Assign]) as [Assign] 
    from																								-- Use sub query to split rights into columns, then outer query gets the Depth
    (select r.name as RoleName, r.businessunitidname as BusinessUnitName, e.Name as EntityName
    , isnull(case when p.AccessRight & 1 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [Read]			-- Use AccessRight to determine action
    , isnull(case when p.AccessRight & 2 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [Write]
    , isnull(case when p.AccessRight & 4 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [Append]
    , isnull(case when p.AccessRight & 16 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [AppendTo]
    , isnull(case when p.AccessRight & 32 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [Create]
    , isnull(case when p.AccessRight & 65536 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [Delete]
    , isnull(case when p.AccessRight & 262144 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [Share]
    , isnull(case when p.AccessRight & 524288 <> 0 then max(rp.PrivilegeDepthMask) end, 0) as [Assign]
    from dbo.FilteredRole r
    join dbo.RolePrivileges rp on r.roleid = rp.roleid
    join dbo.FilteredPrivilege p on rp.privilegeid = p.privilegeid
    join dbo.PrivilegeObjectTypeCodes potc on p.privilegeid = potc.privilegeid
    join MetadataSchema.Entity e on potc.ObjectTypeCode = e.ObjectTypeCode
    group by r.name, r.businessunitidname, e.Name, p.AccessRight) as Role
    group by RoleName, BusinessUnitName, EntityName
    
    -- General Privileges
    select r.name as RoleName, r.businessunitidname as BusinessUnitName, p.Name as PrivilegeName
    , max(rp.PrivilegeDepthMask) as Depth
    from 
    dbo.FilteredPrivilege p 
    join dbo.RolePrivileges rp on rp.privilegeid = p.privilegeid
    join dbo.FilteredRole r on r.roleid = rp.roleid
    join dbo.PrivilegeObjectTypeCodes potc on p.privilegeid = potc.privilegeid
    join MetadataSchema.Entity e on potc.ObjectTypeCode = e.ObjectTypeCode
    -- Filter out Entity privileges
    where p.Name <> 'prv' 
    	+ case p.AccessRight 
    		when 1 then 'Read' 
    		when 2 then 'Write'
    		when 4 then 'Append'
    		when 16 then 'AppendTo'
    		when 32 then 'Create'
    		when 65536 then 'Delete'
    		when 262144 then 'Share'
    		when 524288  then 'Assign' 
    	end					-- Not all privileges reflect the entity name, so map those that differ
    	+ case 
    		when e.IsActivity = 1 or e.Name = 'ActivityPointer' then 'Activity'
    		when e.Name = 'SalesOrder' then 'Order'
    		when e.Name = 'KbArticle' then 'Article'
    		when e.Name = 'Annotation' then 'Note'
    		when e.Name = 'SystemUser' then 'User'
    		when e.Name = 'Annotation' then 'Note'
    		when e.Name = 'BusinessUnitNewsArticle' then 'NewsArticle'
    		when e.Name = 'Template' then 'EmailTemplate'
    		when e.Name = 'KbArticleTemplate' then 'ArticleTemplate'
    		when e.Name = 'SalesProcessInstance' then 'AsyncOperation'
    		when e.Name = 'SavedQuery' then 'Query'
    		when e.Name = 'CustomerAddress' then 'Account'
    		when e.Name in ('SdkMessageRequestField', 'SdkMessageRequest', 'SdkMessageRequestInput', 'SdkMessagePair', 'SdkMessageFilter', 'SdkMessageResponse', 'SdkMessageResponseField') then 'SdkMessage'
    		when e.Name in ('ConstraintBasedGroup', 'Resource', 'ResourceSpec', 'ResourceGroup') then 'Service'
    		when e.Name in ('DiscountType', 'PriceLevel', 'UoMSchedule') then 'Product'
    		else e.Name
    	end
    group by r.name, r.businessunitidname, p.Name 
    
    


  • Community Member Profile Picture
    on at

    Thanks David. We have Dynamics 365 but we don't have development environment setup for executing such queries. Does Dynamics CRM SDK allows executing SQL queries for Dynamics 365 instance ?

  • Suggested answer
    Ryan Maclean Profile Picture
    3,070 on at

    You could use the MS CRM Security Roles to Excel Export tool that's available on CodePlex - mscrmrolesheetexporter.codeplex.com

    It works pretty well

  • Community Member Profile Picture
    on at

    Nice but its not working. While installation its giving following error:

    The solution file is invalid. The compressed file must contain the following files at its root: solution.xml, customizations.xml, and [Content_Types].xml. Customization files exported from previous versions of Microsoft Dynamics 365 are not supported.

  • Suggested answer
    Ryan Maclean Profile Picture
    3,070 on at

    You don't need to import it to CRM.  Unzip it and then run the application, it's a standalone

  • Community Member Profile Picture
    on at

    Thanks Ryan, But it seems I have a bad day today.

    Source : Not Provided

    Method : Not Provided

    Date : 29.08.2017

    Time : 15:06:00

    Error : A CRM server name is required.

    Parameter name: CrmServerName

    Stack Trace : Not Provided

    Below is the interface but the Username and Pass is cleared for the sake of privacy.

    2084.error.png

  • rath.amit38@gmail.com Profile Picture
    2 on at

    It worked for me!!! Thank you Ryan.

  • Community Member Profile Picture
    on at

    Where you have mentioned the server name and are you using Dynamics 365 or some other version ?

  • Suggested answer
    Ryan Maclean Profile Picture
    3,070 on at

    I just tried it on an Online instance and it has worked for me.  Have you input your username as your O365 email address?

    If you've exhausted all other options then i'd recommend raising a discussion/issue on the CodePlex forum and hopefully the person who made it will be able to assist. I think he's also a users on these Forums so you may be able to get assistance that way.

    Otherwise, you could try downloading SnapShot, though this is a paid application - www.xrmcoaches.com/snapshot

  • Community Member Profile Picture
    on at

    Yes I entered the correct username and password. But it did not worked, I tried it multiple times. Anyhow thanks for your responses. I will put a thread on the codeplex web

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans