Friday, April 4, 2014

MS CRM 2013 Online upgrade to Office 365 authentication

Recently many CRM Online customers were transitioned from Live ID to Office 365 authentication.

The result is that the earlier Live ID users accounts no longer exist and any software still using Live ID authentication stopped working.

This requires updating how any portal code authenticates and using a new Office 365 user account to authenticate with.

In addition the CRM 2013 Email Router needs to be reconfigured and updated to the Rollup 2 version ( at this moment in time ).

O365 Authentication

If you start with the latest CRM 2013 SDK  example AuthenticateWithNoHelp solution, you can add the code snippet below to the file  AuthenticateWithNoHelp.cs to get O365 authentication to work.


First open and compile this solution. Than add the code snippet below to the AuthenticationWithNoHelp class.

The following gives you an IOrganizationService and an IOrganizationServiceContext

If you are incorporating this into an existing CRM 2011 solution, you will need to update your Microsoft.Xrm.Client and Microsoft.Xrm.Sdk references.

The global variables beginning with underscores are used internally in the AuthenticationWithNoHelp class. Substitute your organization name for {orgname}.

public IOrganizationService OrgService { get; set; }
public OrganizationServiceContext OrgContext { get; set; }

private String _discoveryServiceAddress = "";
private String _userName = "newusername@{orgname}";
private String _password = "password";
private String _domain = "";

public Authenticate()
IServiceManagement<IDiscoveryService> serviceManagement = ServiceConfigurationFactory.CreateManagement<IDiscoveryService>(new Uri(_discoveryServiceAddress));
AuthenticationProviderType endpointType = serviceManagement.AuthenticationType;

IServiceManagement<IOrganizationService> orgServiceManagement = ServiceConfigurationFactory.
CreateManagement<IOrganizationService>( new Uri("https://{orgname} "));

AuthenticationCredentials credentials = GetCredentials(orgServiceManagement, endpointType);

using (OrganizationServiceProxy organizationProxy =
GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceManagement, credentials))
OrgService = organizationProxy;


OrgContext = new OrganizationServiceContext(organizationProxy);

Email Router
If you are running an older version of the email router update to the appropriate 32 or 64 bit version found here.
Install and reboot.
To reconfigure your Email Router:
1. Change the Server URL  from to
2. Change the User Name and Password to new a new Office 365 account

Then under Configuration Profiles Set the Outgoing Access Credentials to match the Office 365 Credentials used above.



  1. Publish your changes
  2. Load Data
  3. Test Access

That may not cover every Email Router configuration change, but it should cover most of them.

No comments: