Sharing a sample code that can be used to connect to CRM 2011 online with Office 365.
// Add refereneces to the following dll
// microsoft.crm.sdk.proxy
// microsoft.xrm.sdk
// system.runtime.serialization
// system.servicemodel
IServiceManagement<IOrganizationService> orgServiceManagement =
ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("https://democrm.api.crm5.dynamics.com/XRMServices/2011/Organization.svc"));
AuthenticationCredentials authCredentials = new AuthenticationCredentials();
authCredentials.ClientCredentials.UserName.UserName = _userName;
authCredentials.ClientCredentials.UserName.Password = _password;
AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);
OrganizationServiceProxy organizationProxy = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);
Guid userid = ((WhoAmIResponse)organizationProxy.Execute(new WhoAmIRequest())).UserId;
Sample Code – Dynamics 365 Web API / Organization Service
Bye.




