Microsoft Dynamics 4.0 SDK Verify that the user is authorized

Earlier, we used unsupported dll ( Microsoft.Crm.Application.Components.Core) to check if the current user in Dynamics has read permissions for a specific object:

Microsoft.Crm.Security.User.HasPrivilege(Microsoft.Crm.Security.User.Current,   
 "myentityname, AccessRights.ReadAccess);

I need to do the same using only the supported SDK (and CrmService).

Can anyone advise how to do this using the SDK?

0
source share
2 answers

Perhaps you can design a Fetch or QueryExpression expression as follows:

  • Get entity privilege
  • Join the roleprivilege entity, where privilege.privilegeid = roleprivilege.privilegeid
  • systemuserrole, systemuserrole.roleid = roleprivileges.roleid systemuserrole.systemuserid = (GUID )
  • , , privilege.name = "prvReadMyEntityName"

, , , , .

+1

:

<fetch mapping="logical" count="1000" version="1.0">
    <entity name="privilege">
        <attribute name="name" />
        <filter>
            <condition attribute="name" operator="eq" value="prvCreateINSERTYOURENTITYHERE" />
        </filter>
        <link-entity name="roleprivileges" from="privilegeid" to="privilegeid">
            <link-entity name="role" from="roleid" to="roleid">
                <link-entity name="systemuserroles" from="roleid" to="roleid">
                    <link-entity name="systemuser" from="systemuserid" to="systemuserid">
                        <filter>
                            <condition attribute="fullname" operator="eq" value="INSERT NAME HERE" />
                        </filter>
                    </link-entity>
                </link-entity>
            </link-entity>
        </link-entity>
    </entity>
</fetch>
+2

All Articles