Error while connecting .NET core console app with d365 crm on-prem

1

I have already connected d365 CRM online with the .net core console app using client id, clients secret, and organization URI. But it is throwing an error on connecting with on-prem.

here is the error.

Microsoft.PowerPlatform.Dataverse.Client.Utils.DataverseConnectionException
HResult=0x80131500
Message=Failed to connect to Dataverse
Source=Microsoft.PowerPlatform.Dataverse.Client
StackTrace:
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient.CreateServiceConnection(Object externalOrgServiceProxy, AuthenticationType requestedAuthType, String hostName, String port, String orgName, NetworkCredential credential, String userId, SecureString password, String domain, String Geo, String claimsHomeRealm, Boolean useSsl, Boolean useUniqueInstance, OrganizationDetail orgDetail, String clientId, Uri redirectUri, PromptBehavior promptBehavior, OrganizationWebProxyClient externalOrgWebProxyClient, String certificateThumbPrint, StoreName certificateStoreName, X509Certificate2 certificate, Uri instanceUrl, Boolean isCloned, Boolean useDefaultCreds, Version incomingOrgVersion, ILogger externalLogger)
at Microsoft.PowerPlatform.Dataverse.Client.ServiceClient..ctor(Uri instanceUrl, String clientId, String clientSecret, Boolean useUniqueInstance, ILogger logger)
at DOHTestCoreConApp.Program.crmConnection() in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 23
at DOHTestCoreConApp.Program.Main(String[] args) in C:\DOH PRP\Code\DOHTestCoreConApp\DOHTestCoreConApp\Program.cs:line 11

This exception was originally thrown at this call stack:
[External Code]

Inner Exception 1:
AggregateException: One or more errors occurred. (Need a non-empty authority (Parameter 'Authority'))

Inner Exception 2:
ArgumentNullException: Need a non-empty authority (Parameter 'Authority')

here is the code

string SoapOrgServiceUri = "http://crm/XRMServices/2011/Organization.svc";
Uri serviceUri = new Uri(SoapOrgServiceUri);

string client_id = "****";
string client_sec = "****";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var cdsClient = new ServiceClient(serviceUri, client_id, client_sec, true);
.net-core
dynamics-crm
dynamics-crm-2011
asked on Stack Overflow Apr 7, 2021 by Mohammad Khubaib Nasir • edited Apr 15, 2021 by Barns

1 Answer

0

On prem doesn't use the azure ad client id / secret. You will need to use an ad account. See https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/active-directory-claims-based-authentication

answered on Stack Overflow Apr 19, 2021 by Brent

User contributions licensed under CC BY-SA 3.0