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
http://nishantrana.wordpress.com/2012/12/06/sample-code-to-connect-office-365-users-to-crm-2011-online/
Bye.


I have an issue with IFD CRM. Am trying to connect to crm with network credentials. but it throwing as “The NetworkCredentials provided were unable to create a Kerberos credential, see inner exception for details.” and am able to connect to crm with username and password.
Please help me….
very easy… thanks!
hello Sir,
I am using CRM 2011 and new to it.
I have an webservice(object) which requires parameter ,the parameters will be the Enities properties which is created in CRM 2011.
like if I have created Enitiy ‘order’ which has fields like pickup date,weight,total amount
and these are parameters which will be required for webservice for Courier.
how would I fetch data from CRM 2011 and pass to webservice .
I known plug-in are used for that, but how to write? and how to access the database?
please some one will explain me how to achieve this task?
all sort of Information are welcomed.
Thanks
To fetch data you can use either QueryExpression or FetchXml. In SDK you can easily find examples for them.
Check this link
http://msdn.microsoft.com/en-us/library/gg334607.aspx
Using XP as Development Platform for CRM 2011:
http://mkonrad.blogspot.com/2010/11/crm-2011-filenotfoundexception-when.html
Hello,
How to avoid of using
new System.Net.NetworkCredential(“admin”,“pwd “,“domain”);
but use WindowsIdentity or pass NTLM authentication details?
Try this Sultan
ClientCredentials credentials = new ClientCredentials();
// set default credentials for OrganizationService
credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
// or
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
Let me know it worked or not.
What are the reasons for the failure of ‘…/XRMServices/2011/Organization.svc’?
I try to test but the CRM says but 20 minutes ago I was ok
An error has occurred.
Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization’s Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.
It didn’t work.
Try by adding the following line
serviceProxy.EnableProxyTypes();
IOrganizationService service = (IOrganizationService)serviceProxy;
This worked for me. And thanks for the original post as well! Really helpful!
Hi!
When I run a sample in CRM 2011 SDK to add a note with a document attachment to the contact’s record. It throws exception:
“The request channel timed out while waiting for a reply after 00:01:59.9069947. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted tho this operation may have been a portion of a longer timeout.”
Note: I use CRM 2011 online. File upload has size 6M, type zip. I set file size limit for attachments to 8M.
I hope you can help me. Thanks!
Hi TrongNguyen,
Create the registry entries as mentioned in this KB article http://support.microsoft.com/kb/918609, also increase the timeout in CRM’s all web.config files, you will need to change these two keys in web.config files executionTimeout=”3600″ maxRequestLength=”20000″, restart your IIS and Async Services instance and I think you will fine.
I try this but it d’nt work for me.
Hi,
I tried running the code as is and I get an error saying:
“base {System.ServiceModel.CommunicationException} = {“The token provider cannot get tokens for target ‘http://crm2011/CRM/XRMServices/2011/Organization.svc’.”}”
Could some one please help as I cannot figure this out.
Thanks in advance
Have anyone solved the exception related to missing assembly Microsoft.IdentityModel 3.5.0.0 on win 7 64 bit os?
OrganizationServiceProxy _serviceProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
If i am not mistaken in this statement the last parameter is device credentials ( i.e. deviceID and DevicePassword) , could you specify for what reson these are passed and in which senario we would pass them.
I need to build connection using Windows live ID. Any specific points to note of it.
Hi,
Were you able to connect your app using Windows Live Id ?
In fact i get an exception which says ” Value cannot be null. Parameter name: DeviceCredentials ”
Any idea what would be going wrong ?
Hi was able to successfully connect.
Device Credentials are always needed while connecting to Online MS CRM.
For this use the deviceidmanager.cs from the helper code. have the needed dlls added.
Make sure the timestamp ( clock skew) is in synch with that of the online CRM.
It should work.
Hi Sanu,
Take a look at soaplogger sample in CRM 2011 SDK
..\sdk\samplecode\cs\client\soaplogger\soaplogger
It makes use of crmservicehelpers.cs which would be of interest to you.
Can you help me fix it?
Metadata contains a reference that cannot be resolved: ‘http://server02/XRMServices/2011/Discovery.svc?wsdl’.
Check for “server02″, there could be some access issues.
Please help me!
I run example “quickstart” in SDK Microsoft Dynamic CRM 2011 and thrown exception:
Could not load file or assembly ‘Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf38564e35′ or one of its dependencies. The system cannot find the file specified.
Can you help me fix it?
Note: My operation operating system is “Win xp sp3 build 2600″ -> I can’t setup Microsoft Identity Model.
Check this url -
http://social.msdn.microsoft.com/Forums/en/Geneva/thread/7d997b28-f8a7-4854-8ab8-2b9ef935f507
Hi How to assing my custome guid while creating entity in CRM 2011 using IOrganizationService in CRM 2011