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)

Need SQL query or view to find privilege

(0) ShareShare
ReportReport
Posted on by 12,119 Moderator

Hi all

I need to find which security role has merge privilege. Is there any query or advanced find view which makes me help to retrieve this kind of information.

Thank you

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Abdul Wahab,

    Try the following query.

    SELECT  DISTINCT
            r.Name
            ,COALESCE(e.OriginalLocalizedName, e.Name) AS [EntityName]
            ,CASE p.AccessRight
                 WHEN 32     THEN 'Create' /* or hex value 0x20*/
                 WHEN 1      THEN 'Read'
                 WHEN 2      THEN 'Write'
                 WHEN 65536  THEN 'Delete' /* or hex value 0x10000*/
                 WHEN 4      THEN 'Append'
                 WHEN 16     THEN 'AppendTo'
                 WHEN 524288 THEN 'Assign' /* or hex value 0x80000*/
                 WHEN 262144 THEN 'Share' /* or hex value 0x40000*/
                 ELSE 'None'
            END AS [Privilege]
            ,CASE (rp.PrivilegeDepthMask % 0x0F)
                 WHEN 1 THEN 'User (Basic)'
                 WHEN 2 THEN 'Business Unit (Local)'
                 WHEN 4 THEN 'Parental (Deep)'
                 WHEN 8 THEN 'Organization (Global)'
                 ELSE 'Unknown'
            END AS [PrivilegeLevel]
            ,(rp.PrivilegeDepthMask % 0x0F) as [PrivilegeDepthMask]
            ,CASE WHEN e.IsCustomEntity = 1 THEN 'Yes' ELSE 'No' END AS [IsCustomEntity]
    FROM    Role AS r
    INNER   JOIN RolePrivileges AS rp 
            ON r.RoleId = rp.RoleId
    INNER   JOIN Privilege AS p 
            ON rp.PrivilegeId = p.PrivilegeId
    INNER   JOIN PrivilegeObjectTypeCodes AS potc 
            ON potc.PrivilegeId = p.PrivilegeId
    INNER   JOIN MetadataSchema.Entity AS e
            ON e.ObjectTypeCode = potc.ObjectTypeCode
    ORDER   BY r.Name, [EntityName]

    Please go through the following link for Dynamics CRM 2011 Security Role SQL query.

    stackoverflow.com/.../dynamics-crm-2011-security-role-sql-query

  • Verified answer
    tw0sh3ds Profile Picture
    5,600 on at

    SELECT r.Name FROM Privilege p

    JOIN RolePrivileges rp on p.PrivilegeId = rp.PrivilegeId

    JOIN Role r on r.RoleId = rp.RoleId

    where p.Name = 'prvMerge'

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