Export (0) Print
Expand All
3 out of 6 rated this helpful - Rate this topic

Connect to the Microsoft Dynamics CRM Server

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Advanced Developer Extensions for Microsoft Dynamics CRM uses the concept of a connection string to connect to the Microsoft Dynamics CRM server. This is similar to the concept of connection strings used with Microsoft SQL Server. Connection strings are a natural part of the ADO.NET framework and also have native support in configuration files, including the ability to encrypt the configuration sections for maximum security. This encourages you to use a robust model in which Microsoft Dynamics CRM connections are configured at deployment time, and are not hard coded in your application. As such, all APIs in Advanced Developer Extensions for Microsoft Dynamics CRM work with a CrmConnection object, used internally by the XrmDataContext class shown in the following example, that uses a connection string to connect to the server.

You will supply this connection string in the app.config or web.config file for your project, as shown here.

<connectionStrings>
  <add name="Crm" connectionString="Authentication Type=Passport;
    Server=https://your-org-name.crm.dynamics.com/your-orgid;
    User ID=your-windowslive-id; Password=your-wlid-password;
    Device ID=your-device-id; Device Password=your-device-password"/>
</connectionStrings>

The connection string is also used when you instantiate an XrmDataContext as shown here.

//Use the Microsoft Dynamics CRM Online connection string from the app.config file.
var crm = new Xrm.XrmDataContext("CRMOnline");

The basic format of the connection string is the same as an OLEDB connection string. It is a series of name/value pairs separated by semicolons. The parameters listed in the following table, which can be entered in any order, are allowed.

Parameter nameDescription
Authentication TypeSpecifies the type of authentication. The Authentication Type parameter can have one of the following values: Integrated, AD, SPLA, or Passport.

Integrated - Used to authenticate with Microsoft Dynamics CRM using the current Windows credentials of the application. This is typically used in making prototypes and in development environments and only works with on-premises deployments in the same Active Directory domain (or trusted domain) as the Microsoft Dynamics CRM server. It does not work for Internet-facing deployments (IFDs) or with Microsoft Dynamics CRM Online.

AD - Used to specify Active Directory credentials of a specific service account. This is used for on-premises deployments and is usually used for production systems.

SPLA - Used for internet facing deployment (IFD). SPLA is an acronym for Service Provider License Agreement, which is the licensing program that partners are required to use to license Microsoft Dynamics CRM in hosting arrangements.

Passport - Used for Microsoft Dynamics CRM Online deployments. This uses the Windows Live ID mechanism, which used to be called Passport. Passport authentication cannot be used with on-premises or internet facing deployment deployments.

ServerSpecifies the URL of the Microsoft Dynamics CRM server. It can be http or https. The port is optional if it is http over port 80 or https over port 443. The server URL is typically in this form:
http://crm-server:port/organization-name

The organization-name is required.

User IDSpecifies the user name of the service account that is used to connect using AD, SPLA, or Passport authentication types. It is not needed for integrated authentication. The format for this is specific to the authentication type: domain\username for AD and SPLA authentication types and a Windows Live ID for Passport authentication.
PasswordSpecifies the password of the service account that is used to connect using AD, SPLA, or Passport authentication.
Device IDSpecifies the device ID. Each connection to the Windows Live service requires a user-defined Device ID that can be any string from 12 to 22 characters in length. This device ID will be registered the first time an authentication is run but will be required for all subsequent authentications with the WLID specified in this connection string.
Device PasswordSpecifies the device password. Each connection to the Windows Live service requires a user-defined device password that can be any string from 12 to 22 characters in length. This device password will be registered the first time an authentication is run but will be required for all subsequent authentications with the WLID specified in this connection string. If the device ID and device password do not match the values that are registered, the authentication will fail.
TimeoutSpecifies the time your XML Web service client waits for a synchronous XML Web service request to complete, in milliseconds.
Discovery URLSpecifies the Discovery URL used by your site if you are connecting to a Microsoft Dynamics CRM Online organization.  To connect to Microsoft Dynamics CRM Online, the discovery service is first hit to retrieve a passport authentication ticket. This ticket indicates that a Live ID user is, in fact, authenticated to use the Microsoft Dynamics CRM Online instance.
PreAuthenticateSpecifies whether to use pre-authentication. This true/false parameter is passed through to the XML Web service to set Preauthenticate in the framework. Setting this value to true may affect performance.
Connection SharingSpecifies whether to use connection sharing. This true/false parameter is passed through to the XML Web service to set UnsafeAuthenticateConnectionSharing in the framework. Setting this value to true may affect performance.
Live ID PartnerSpecifies a custom Live ID Partner URL that will override the default http://crm.dynamics.com

Examples

The following example shows the connection string using integrated authentication:

AuthenticationType=Integrated; Server=http://crm-server-name/crm-organization-name

The following example shows the connection string using Active Directory authentication:

Authentication Type=AD; Server=http://crm-server-name:port/crm-organization-name; User ID=user-domain\user-name; Password=user-password

The following example shows the connection string for an Internet-facing deployment (IFD):

Authentication Type=SPLA; Server=http://crm-server-name/crm-organization-name; User ID=user-domain\user-name; Password=user-password 

The following example shows the connection string using Windows Live ID to connect to Microsoft Dynamics CRM Online:

Authentication Type=Passport; Server=https://crm-organization-name.crm.dynamics.com/crm-organization-name; User ID=user-windows-live-id; Password=user-password; Device ID=user-defined-device-id; Device Password=user-defined-device-password 

See Also

Concepts


© 2010 Microsoft Corporation. All rights reserved.


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.