Problem using crmsvcutil to generate data context class
I am trying 开发者_运维百科to retrieve data from Microsoft Dynamics CRM database. In order to have LINQ functionality, I applied crmsvcutil to generate data context class. The following is the command line I used
crmsvcutil /connectionString:"Authentication Type=SPLA; Server= http://our-crm.com; User ID=user; Password=pass" /namespace:Stub.Xrm /dataContextPrefix:MyCorp /out:Xrm.cs
When running the command, I got
Unhandled Exception: System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
Error. I was able to access http://our-crm.com by using user/pass to assess the CRM. I am suspecting that the URL of serer was the problem, but don't know exactly which one I should use.
The CRM version I used is 4.0
UPDATE On May 19, 2011: I changed the connection string to
crmsvcutil /connectionString:"Authentication Type=AD; Server= http://our-crm.com/CRM; User ID=domain\user; Password=pass" /namespace:Stub.Xrm /dataContextPrefix:MyCorp /out:Xrm.cs
Now I am getting
Unhandled Exception: System.ApplicationException: 0x80040220
SecLib::CheckPrivilege failed. Returned hr = -2147220960, User: f26255aa-997a-e011-b1ff-0050569e0924, PrivilegeId: a33
11f47-2134-44ee-a258-6774018d4bc3
Does it mean I do not have enough privilege to retrieve WSDL information? But I was able to use browser to get http://our-crm.com/mscrmservices/2007/CrmServiceWsdl.aspx and I was able to add webreference to the WebService using same credential.
If you are accessing Dynamics CRM OnPremise with the credentials of the current user, you have to specify Integrated
as authentication type.
Therefore your connection string should be
/connectionString:"Authentication Type=Integrated; Server= http://our-crm.com;
If you have to specify a specific user, you have to use AD
/connectionString:"Authentication Type=AD; Server= http://our-crm.com; User ID=user-domain\user-name; Password=user-password
See Connect to the Microsoft Dynamics CRM Server
精彩评论