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

Announcements

News and Announcements icon
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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans