将连接传递到 Dynamics 365 CRM 后获取服务
Getting the service after passing the connection to Dynamics 365 CRM
我一直在发布有关 Dynamics 365 集成的问题,我将简要解释我遇到的问题 facing.The 我用来连接的代码是这样的
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
CrmServiceClient conn = new CrmServiceClient(new NetworkCredential("<username>", "<Password>", "<domain>"), Microsoft.Xrm.Tooling.Connector.AuthenticationType.IFD, "<url>", "<port>", "<OrgName>");
_orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
// Retrieve the version of Microsoft Dynamics CRM.
RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse = (RetrieveVersionResponse)_orgService.Execute(versionRequest);
Console.WriteLine("Microsoft Dynamics CRM version {0}.", versionResponse.Version);
凭据不会 return 服务请求,这是我收到的错误日志。
Inner Exception Level 3 :
Source : System
Method : Receive
Date : 26/09/2018
Time : 11:19:51 AM
Error : An existing connection was forcibly closed by the remote host
Stack Trace : at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32
offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationWebProxyClient is null
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
The application terminated with an error.
Microsoft 使用工具连接器的示例程序中的 None 无法运行。我无法使用 OrganizationClient 连接,因为集成不会 运行 使用 Microsoft.SDK.Client.dll。我被困在这里,我想知道这是否是托管 CRM 的问题。如有任何帮助,我们将不胜感激。
您需要在连接字符串中包含 AuthType=Office365。
将代码的第 2 行替换为下面的这两行。
其中
- {url} 是您的 D365 实例 URL
- {username} 是您的 D365 用户名(尝试:username 或 domain\username)
- {password} 是您的 D365 密码
- {hru} 是您的 ADFS 主域 url
{domain} 是您的 AD 域
字符串构造 = $"AuthType=IFD;HomeRealmUri={hru};Domain={domain};Url={url};Username={username};Password={pass}";
CrmServiceClient 服务 = new CrmServiceClient(conStr);
我很少需要设置安全协议,因此您可以尝试跳过设置安全协议并在 CrmServiceClient
构造函数中使用简单的连接字符串。
首先,根据你的版本设置连接字符串:
CRM 2016 之前的本地 IFD:
var connectionString = "Url=https://contoso.litware.com; Username=someone@litware.com; Password=password; AuthType=IFD;"
CRM 2016 及更高版本 (v8.0+) 的本地 IFD
var connectionString = "ServiceUri=https://contoso.litware.com/contoso; Domain=contoso; Username=contoso\administrator; Password=password; AuthType=IFD; LoginPrompt=Never;"
然后传入构造函数:
var svc = new CrmServiceClient(connectionString);
然后您可以检查服务是否就绪:
if(!svc.IsReady) { throw new Exception("Service not ready");}
我一直在发布有关 Dynamics 365 集成的问题,我将简要解释我遇到的问题 facing.The 我用来连接的代码是这样的
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
CrmServiceClient conn = new CrmServiceClient(new NetworkCredential("<username>", "<Password>", "<domain>"), Microsoft.Xrm.Tooling.Connector.AuthenticationType.IFD, "<url>", "<port>", "<OrgName>");
_orgService = (IOrganizationService)conn.OrganizationWebProxyClient != null ? (IOrganizationService)conn.OrganizationWebProxyClient : (IOrganizationService)conn.OrganizationServiceProxy;
// Retrieve the version of Microsoft Dynamics CRM.
RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse = (RetrieveVersionResponse)_orgService.Execute(versionRequest);
Console.WriteLine("Microsoft Dynamics CRM version {0}.", versionResponse.Version);
凭据不会 return 服务请求,这是我收到的错误日志。
Inner Exception Level 3 :
Source : System
Method : Receive
Date : 26/09/2018
Time : 11:19:51 AM
Error : An existing connection was forcibly closed by the remote host
Stack Trace : at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32
offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : Unable to Login to Dynamics CRM
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationWebProxyClient is null
Microsoft.Xrm.Tooling.Connector.CrmServiceClient Error: 2 : OrganizationServiceProxy is null
The application terminated with an error.
Microsoft 使用工具连接器的示例程序中的 None 无法运行。我无法使用 OrganizationClient 连接,因为集成不会 运行 使用 Microsoft.SDK.Client.dll。我被困在这里,我想知道这是否是托管 CRM 的问题。如有任何帮助,我们将不胜感激。
您需要在连接字符串中包含 AuthType=Office365。
将代码的第 2 行替换为下面的这两行。 其中
- {url} 是您的 D365 实例 URL
- {username} 是您的 D365 用户名(尝试:username 或 domain\username)
- {password} 是您的 D365 密码
- {hru} 是您的 ADFS 主域 url
{domain} 是您的 AD 域
字符串构造 = $"AuthType=IFD;HomeRealmUri={hru};Domain={domain};Url={url};Username={username};Password={pass}"; CrmServiceClient 服务 = new CrmServiceClient(conStr);
我很少需要设置安全协议,因此您可以尝试跳过设置安全协议并在 CrmServiceClient
构造函数中使用简单的连接字符串。
首先,根据你的版本设置连接字符串:
CRM 2016 之前的本地 IFD:
var connectionString = "Url=https://contoso.litware.com; Username=someone@litware.com; Password=password; AuthType=IFD;"
CRM 2016 及更高版本 (v8.0+) 的本地 IFD
var connectionString = "ServiceUri=https://contoso.litware.com/contoso; Domain=contoso; Username=contoso\administrator; Password=password; AuthType=IFD; LoginPrompt=Never;"
然后传入构造函数:
var svc = new CrmServiceClient(connectionString);
然后您可以检查服务是否就绪:
if(!svc.IsReady) { throw new Exception("Service not ready");}