Back in November I released the first version of the Data8.PowerPlatform.Dataverse.Client NuGet package to let developers connect to on-prem Dynamics CRM/365 instances using claims-based or IFD authentication without having to configure OAuth.
I’ve now released an update to this package – version 2.0.0 also includes support for Active Directory (AD) authentication too!
You can continue to use this package in exactly the same way as before – give it the URL of the organization service and the username and password to authenticate as, and you get back a standard
IOrganizationService instance you can use in exactly the same way as the standard Microsoft SDK.
var svc = new OnPremiseClient("https://crm.contoso.com/org/XRMServices/2011/OrganizationService.svc", "AD\\username", "password"); var qry = new QueryExpression("contact"); qry.Criteria.AddCondition("firstname", ConditionOperator.Equal, "Mark"); qry.Criteria.AddCondition("lastname", ConditionOperator.Equal, "Carrington"); var results = svc.RetrieveMultiple(qry);
You can also authenticate as the currently logged in user by leaving the username and password parameters set to
OnPremiseClient class will automatically detect whether the instance you’re connecting to supports claims based authentication or Active Directory authentication.
NOTE: Active Directory authentication will only work when the client is running on Windows. If you need it on Linux and are familiar with the GSS API, please get in touch!
I’ve tested this library on the on-prem servers I have available, but if there’s one thing I’ve learned working with on-prem is that there’s a huge range of ways that they end up being configured – not all of them correct/supported. If you do have any problems authenticating with this library I’d love to hear about it so I can update it as necessary for other configurations.
Many thanks again to Data8 for agreeing to open-source this library. I’m also very thankful for the work on the NSspi library which helped tremendously.
3 thoughts on “On-Prem Dynamics CRM/365: AD authentication from .NET Core”
Hi Mark. Thanks for useful implementation. I tried it and it was enjoyable! Just a question. Why it doesn’t support HTTP? Is there any way to add it?
Adding HTTP support requires a lot more encryption to be done by the client itself. I don’t have a need for this myself, but I’d be happy to review a PR that adds it if you want to have a go at it.