我已经为CRM在线2015发布了一个Post | sync | sandbox |更新消息CRM插件,除了RetrieveMultiple
调用之外一切正常
我创建了IOrganizationService
public static IOrganizationService GetOrganizationServiceByCurrentUser(this IServiceProvider serviceProvider)
{
var serviceFactory = serviceProvider.GetService<IOrganizationServiceFactory>();
var context = serviceProvider.GetService<IPluginExecutionContext>();
return serviceFactory.CreateOrganizationService(context.UserId);
}
致电RetrieveMultiple
Entity config = organizationService.RetrieveMultiple(new FetchExpression(CrmConstants.Query.AzureCofig))
.Entities.FirstOrDefault();
出现以下错误
未在配置的身份验证端点上找到用户名 安全令牌服务!
我尝试过同样的单元测试,CrmConnection
一切正常。看起来插件执行权有问题。有什么想法吗?
答案 0 :(得分:2)
如果检索任何配置部分,则必须在系统帐户下创建IOrganizationService,而不是用户上下文
public static IOrganizationService GetOrganizationServiceByCurrentUser(this IServiceProvider serviceProvider)
{
var serviceFactory = serviceProvider.GetService<IOrganizationServiceFactory>();
return serviceFactory.CreateOrganizationService(null);
}