本文介绍了如何在服务器端的MS Dynamics CRM中获得当前的用户特权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究MS CRM插件,它应该能够确定当前用户是否对当前实体具有写权限。我不知道如何处理此任务。

I'm working on MS CRM plugin, and it should be able to determine whether the current user has write access to the current entity. I don't know how to approach this task.

似乎最人性化的方式当前完成此任务是。

It seems that the most user-friendly way accomplish this task is currently unsupported.

MS CRM 2011 SDK中是否有其他选择,除了编写FetchXML查询并解析其输出外?

Is there any alternative in MS CRM 2011 SDK, except composing a FetchXML query and parsing its output?

推荐答案

这就是我想出的内容-该代码将检查当前用户是否对当前记录赋予了特权:

Here is what I have come up with — this code will check, does current user has given privilege on current record:

// Requesting user's access rights to current record
var principalAccessRequest = new RetrievePrincipalAccessRequest
{
    Principal = new EntityReference("systemuser", localContext.PluginExecutionContext.UserId),
    Target = new EntityReference(localContext.PluginExecutionContext.PrimaryEntityName, localContext.PluginExecutionContext.PrimaryEntityId)
};

// Response will contain AccessRights mask, like AccessRights.WriteAccess | AccessRights.ReadAccess | ...
var principalAccessResponse = (RetrievePrincipalAccessResponse)localContext.OrganizationService.Execute(principalAccessRequest);

if ((principalAccessResponse.AccessRights & AccessRights.WriteAccess) != AccessRights.None)
{
    ...
    ...
    ...
}

if WriteAccess ,则将执行$ c>语句。

The code inside if statement will be executed if user has WriteAccess to current record.

这篇关于如何在服务器端的MS Dynamics CRM中获得当前的用户特权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 05:40