问题描述
我是 WCF 的新手,我创建了 WCF 服务,该服务连接并从动态 CRM 中提取数据。一切正常,但 5 小时后我收到以下错误,由于此错误,我看到异常 The user authentication Failed!
。我知道安全令牌已过期,因此我收到身份验证错误,重新启动应用程序池后一切似乎都很好。
什么会导致安全令牌过期?或者如何重新发行令牌?
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Warning: 4 : Claims Connection reset tripped SecurityToken is Not Null Start From is Valid True End At is Valid False Microsoft.Xrm.Tooling.Connector.CrmServiceClient Warning: 4 : Re-Authenticating due to expired token @ 05/20/2021 04:12:23
我在连接字符串中使用 AuthType=IFD
,下面是我的编码,我从 web.config 文件传递连接字符串。我在配置文件中使用 RequireNewInstance=True;
,因为我有两个 crm 服务器要连接。
<add name="crmconnectionstring" connectionString="Url=https://urlhere; AuthType=IFD; RequireNewInstance=True;Domain=testdomain; Username=testusername; Password=; " />
public OrganizationServiceProxy service_;
CrmServiceClient CrmServiceClient_= new
CrmServiceClient(ConfigurationManager.ConnectionStrings["crmconnectionstring"].ConnectionString);
if (!CrmServiceClient_.IsReady)
{
if (CrmServiceClient_.LastCrmException != null)
throw CrmServiceClient_.LastCrmException;
throw new InvalidOperationException(CrmServiceClient_.LastCrmError);
}
service_ = CrmServiceClient_.OrganizationServiceProxy;
更新 1:
我已尝试更新令牌,但仍然无效。我正在拼命寻求支持。
public OrganizationServiceProxy service;
service = CrmServiceClient_.OrganizationServiceProxy; if (null != this.service.SecurityTokenResponse && DateTime.UtcNow.AddMinutes(15) >= this.service.SecurityTokenResponse.Response.Lifetime.Expires) { 尝试 { this.service.Authenticate(); } 捕获(通信异常) { if (null == this.service.SecurityTokenResponse || DateTime.UtcNow >= this.service.SecurityTokenResponse.Response.Lifetime.Expires) { 扔; } } }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)