我在Dynamics CRM 2011的本地环境中,我希望获得用户具有读取权限的所有帐户。到目前为止,我只是接触到以下内容,但只是检查用户是否具有ReadAcces。但我想查询一次并填充用户具有读取权限的所有帐户。
columns.Add(c => c.Amount)
.Titled("PO Amount")
.SetWidth(400)
.RenderValueAs(x=>String.Format("<span class=\"pull-right\">{0}</span>",c.Amount))
.Encoded(false)
Sanitized(false);
答案 0 :(得分:0)
如果您只想要某个用户可以阅读的帐户列表,请在调用SDK时使用CallerId参数:
https://msdn.microsoft.com/en-us/library/gg309629.aspx
这将执行API调用,就像它来自该用户一样,并且只返回允许用户查看的记录。
// Retrieve the system user ID of the user to impersonate.
OrganizationServiceContext orgContext = new OrganizationServiceContext(_serviceProxy);
_userId = (from user in orgContext.CreateQuery<SystemUser>()
where user.FullName == "Kevin Cook"
select user.SystemUserId.Value).FirstOrDefault();
// To impersonate another user, set the OrganizationServiceProxy.CallerId
// property to the ID of the other user.
_serviceProxy.CallerId = _userId;
// Use serviceProxy for any API calls and it will run as the above user