Simplified Connection To Dynamics CRM 2016 Onpremise Using Console Application

No comments

Here is the quick code that i use when i have to build a console application that connects to dynamics crm onpremise version with AD/IFD Authentication.

Main Class:

ClientCredentials _clientCreds = new ClientCredentials();
_clientCreds.Windows.ClientCredential.UserName = ConfigurationManager.AppSettings["username"];
_clientCreds.Windows.ClientCredential.Password = ConfigurationManager.AppSettings["password"];
_clientCreds.Windows.ClientCredential.Domain = ConfigurationManager.AppSettings["domain"];
var organizationUri = ConfigurationManager.AppSettings["CRMUrl"];

_service = (IOrganizationService)new OrganizationServiceProxy(new Uri(organizationUri), null, _clientCreds, null);

OrganizationServiceContext _orgContext = new OrganizationServiceContext(_service);


<?xml version="1.0" encoding="utf-8"?>
<section name="AppSettings" type="System.Configuration.AppSettingsSection, System.Configuration, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
<add key="CRMUrl" value="" />
<add key="Username" value="rawishkumar" />
<add key="Password" value="password" />
<add key="Domain" value ="exampledomain"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>


Required Assemblies:

using System.ServiceModel.Description;

using System.Configuration;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Client;

Hope this helps!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.