Monday, November 2, 2015

Microsoft Dynamics CRM getting organization(s) endpoint

Microsoft Dynamics CRM Online gives you options for segregating your CRM data and user access. For most companies, adding and using multiple instances in your subscription provides the right mix of functionality and ease of management. Enterprises with separate geographic locations might consider using multiple tenants to separate Microsoft Dynamics CRM Online licenses. Multiple instances can share users among instances; multiple tenants cannot.

In order to get instances (Organization) configured in your account we use discovery service. Discovery service provides the organizations that are available on your Microsoft Dynamics Server. It uses SOAP protocol. 

Given below list of discovery service (Online) hosted by Microsoft for different geo locations.

LocationDiscovery Web service URLIdentity Provider
North America
https://dev.crm.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft account
https://disco.crm.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
North America 2
https://disco.crm9.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Europe, Middle East and Africa (EMEA)
https://dev.crm4.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft account
https://disco.crm4.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Asia Pacific Area (APAC)
https://dev.crm5.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft account
https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Oceania
https://disco.crm6.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
Japan (JPN)
https://disco.crm7.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
South America
https://disco.crm2.dynamics.com/XRMServices/2011/Discovery.svc
Microsoft Office 365
For On-Premise the URL would be: 
http://ServerName/XRMServices/2011/Discovery.svc

Code to get organization endpoints for all the instances configured in Microsoft Dynamics CRM Online.

string discoveryURL = https://disco.crm5.dynamics.com/XRMServices/2011/Discovery.svc";                 
          
//Pass your online account credentials           
ClientCredentials credentials = new ClientCredentials();
credentials.UserName.UserName = "abhishek@xxxxxxxxx.onmicrosoft.com";
credentials.UserName.Password = "xxxxxxxxxxx";

//Create discovery service proxy
DiscoveryServiceProxy dsp = new DiscoveryServiceProxy(new Uri(discoveryURL), null, credentials, null);
dsp.Authenticate();
          
//Retrieve Organization details
RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
RetrieveOrganizationsResponse allOrgs = (RetrieveOrganizationsResponse)dsp.Execute(orgRequest);
//Print all organization(s)(instances) endpoint.
foreach (OrganizationDetail orgInfo in allOrgs.Details)
   {               
     Console.Write(orgInfo.Endpoints[EndpointType.OrganizationService]);
   }

Console.ReadLine();

No comments:

Post a Comment