Home > CRM 2015 > Connecting to CRM from other applications using CrmConnection class – CRM 2015

Connecting to CRM from other applications using CrmConnection class – CRM 2015

Assume that you have an ASP.Net web application and you want to retrieve Contacts from CRM and display in a grid.

Before CRM 2015, to establish a connection with CRM we need to create a service proxy with user credentials (Refer article).

With CRM 2015, we can use “Connection Strings” to connect to the CRM server from external application.

You define the CRM connection strings in <web.config> or <app.config> as below



    <!– Online using Office 365 –>

<!– <add name=”Server=CRM Online, organization=contoso, user=someone” connectionString=”Url=https://contoso.crm.dynamics.com; Username=someone@contoso.onmicrosoft.com; Password=password;”/> –>

    <!– Online using Microsoft account (formerly Windows Live ID) –>

<!– <add name=”Server=CRM Online, organization=contoso, user=someone@example.com” connectionString=”Url=https://contoso.crm.dynamics.com; Username=someone@example.com; Password=password; DeviceID= DevicePassword= “/>–>

    <!– On-premises with provided user credentials –>

<!– <add name=”Server=myserver, organization=AdventureWorksCycle, user=administrator” connectionString=”Url=http://myserver/AdventureWorksCycle; Domain=mydomain; Username=administrator; Password=password;”/> –>

    <!– On-premises using Windows integrated security –>

<!–<add name=”Server=myserver, organization=AdventureWorksCycle” connectionString=”Url=http://myserver/AdventureWorksCycle;”/>–>

    <!– On-premises (IFD) with claims –>

<!–<add name=”Server=litware.com, organization=contoso, user=someone@litware.com” connectionString=”Url=https://contoso.litware.com; Username=someone@litware.com; Password=password;”/>–>



And you can establish connection in your code as below

// ‘CRMOnline’ is ConnectionString name defined in <web.config> or <app.config>

var connection = new CrmConnection(“CRMOnline”);

var service = new OrganizationService(connection);

var context = new CrmOrganizationServiceContext(connection);

Refer MSDN article for more details


Categories: CRM 2015 Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: