2011-05-19 49 views
0

我试图从Microsoft Dynamics CRM数据库检索数据。为了具有LINQ功能,我使用crmsvcutil来生成数据上下文类。下面是我用使用crmsvcutil生成数据上下文类的问题

crmsvcutil /connectionString:"Authentication Type=SPLA; Server= http://our-crm.com; User ID=user; Password=pass" /namespace:Stub.Xrm /dataContextPrefix:MyCorp /out:Xrm.cs 

当运行命令在命令行中,我得到了

Unhandled Exception: System.Net.WebException: The request failed with HTTP status 401: Unauthorized. 

错误。我能够通过使用用户/合格来访问http://our-crm.com来评估CRM。我怀疑serer的网址是问题,但不知道我应该使用哪一个。

我用

的CRM版本为4.0

UPDATE 2011年5月19日: 我改变了连接字符串

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 

现在我越来越

Unhandled Exception: System.ApplicationException: 0x80040220 
    SecLib::CheckPrivilege failed. Returned hr = -2147220960, User: f26255aa-997a-e011-b1ff-0050569e0924, PrivilegeId: a33 
11f47-2134-44ee-a258-6774018d4bc3 

不这意味着我没有足够的特权来检索WSDL信息?但我能够使用浏览器获得http://our-crm.com/mscrmservices/2007/CrmServiceWsdl.aspx,并且我能够使用相同的凭证将Web参考添加到WebService。

+0

你在输入凭据网页表单或在Windows凭据弹出? – ccellar 2011-05-19 07:25:09

+0

当我从浏览器访问crm系统时,我在Windows凭据弹出窗口中输入凭证。这是否意味着我应该将身份验证类型替换为“AD”而不是SPLA? – 2011-05-19 15:55:04

+0

我将身份验证类型更改为AD和用户名至域\用户。我进一步了,输出控制台打印出“建立建议名称列表...”,但是之后再次打印相同的异常消息。 – 2011-05-19 16:00:48

回答

0

如果您正在使用当前用户的凭据访问Dynamics CRM OnPremise,则必须指定Integrated作为身份验证类型。

因此您的连接字符串应该是

/connectionString:"Authentication Type=Integrated; Server= http://our-crm.com; 

如果你必须指定一个特定的用户,你必须使用AD

/connectionString:"Authentication Type=AD; Server= http://our-crm.com; User ID=user-domain\user-name; Password=user-password 

Connect to the Microsoft Dynamics CRM Server

+0

我尝试了Integrated和AD。有同样的例外。 – 2011-05-19 16:08:42