Just a sample code for quick reference !
Uri organizationUri = new Uri("http://crmservername/orgname/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
// set default credentials for OrganizationService
credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
// or
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
IOrganizationService _service = (IOrganizationService)orgProxy;
try
{
Entity myAccount = new Entity("account");
myAccount["name"] = "Test Account";
_service.Create(myAccount);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
In case of early-bound, don’t forget to add the following line of code
OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null); // This statement is required to enable early-bound type support. _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
For Office 365 check this post
https://nishantrana.wordpress.com/2012/12/06/sample-code-to-connect-office-365-users-to-crm-2011-online/
Bye.
