CRM WebService 域验证 获取service
发布时间:2020-12-16 22:50:27 所属栏目:安全 来源:网络整理
导读:今天折磨了一小天总算把问题解决了,首先描述一下问题。 1,写CRM2011 的webService接口,在查询数据的时候需要进行权限控制。 首先想到的办法是用CRM中标准的 IOrganizationService 对象,但是常规的方法中必须要知道登录的用户名,密码才能生成对象。 但实际
今天折磨了一小天总算把问题解决了,首先描述一下问题。 [WebMethod]
public int getService()
{
Uri orgServiceUri = new Uri("http://localhost:5555/orgName/XRMServices/2011/Organization.svc");
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(orgServiceUri,null,credentials,null);
IOrganizationService crmService = (IOrganizationService)crmServiceProxy;
//crmService.Delete("contact",new Guid("B53FA2A9-76CB-E411-8BE6-B82A72D5A332"));
String fetchXml = @"<fetch mapping=""logical"" count=""50"" version=""1.0""> <entity name=""contact""> <attribute name=""address1_telephone1"" /> <attribute name=""contactid"" /> <attribute name=""firstname"" /> <attribute name=""lastname"" /> </entity> </fetch>";
// Build fetch request and obtain results.
RetrieveMultipleRequest efr = new RetrieveMultipleRequest()
{
Query = new FetchExpression(fetchXml)
};
EntityCollection entityResults = ((RetrieveMultipleResponse)crmService.Execute(efr)).EntityCollection;
int count = 0;
count = entityResults.Entities.Count;
return count;
}
换两个有不同角色的用户调用该方法,返回的值如下: (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 管道Vim缓冲区到stdout
- 使用webpack构建angular2应用程序 – 找不到./compiler.es5
- SpreadJS 在 Angular2 中支持哪些事件?
- EditPlus、Notepad++等编辑器选中列(块)的方法
- webservice中使用session的方法
- Unix / Linux OS上的可用磁盘空间
- angular2 – Angular 2 – promise vs observable
- 服务中的Angular 4数据,传递给组件
- angular1.x和angular2+并行,angular1.x 升级 angular2+方案
- angular – 未捕获(承诺):错误:无法找到加载’Achivement