none
[求助]MSCRM2011 web service request相关问题 RRS feed

  • 问题

  • 大家好,

    我现在遇到如下一个问题,当我把我的web application部署到IIS7.5时,我在部署服务器上运行http://localhost:8888/testAPP,一切运行正常,但当我使用ip http://10.2.5.169:8888/testAPP访问时遇到如下问题:The caller was not authenticated by the service. 希望能够得到大家的帮助,先谢谢大家了。

    我的代码如下:

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Xrm.Sdk.Client;
    using Microsoft.Crm.Sdk.Messages;
    using Microsoft.Xrm.Sdk.Query;
    using System.ServiceModel;
    using System.ServiceModel.Description;
    using System.Net;
    using System.Data;
    
    namespace TestSimpleWebDeploy
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                CreateCompte();
                Response.Write("OK");
            }
    
            
            private void CreateCompte()
            {
                try
                {
                    OrganizationServiceProxy _serviceProxy;
                    IOrganizationService _service;
    
                    Uri org = new Uri("http://crmmaq.HSBC.local/CRMMAQ/XRMServices/2011/Organization.svc");
                    ClientCredentials credentials = new ClientCredentials();
                    credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
    
                    using (_serviceProxy = new OrganizationServiceProxy(org,
                                                                        null,
                                                                        credentials,
                                                                        null))
                    {
                        _service = (IOrganizationService)_serviceProxy;
    
                        Entity testCompte=new Entity("account");
                        testCompte.Attributes["name"]="HSBC";
                        _service.Create(testCompte);
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
    
        }
    }

     Web.config如下,

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
    
      <appSettings />
      <connectionStrings />
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
                <authentication mode="Windows" />
    
         <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
            <identity impersonate="true" />
      </system.web>
    </configuration>

    IIS7.5 部署情况,激活ASP .NET和Windows Anthencation验证,


    crm4.0学步

    2011年11月30日 10:21

全部回复

  • IP 地址没有办法使用 AD 的验证。如果需要用 IP 地址, 请使用 UserName 和 Password 的验证。

    问题在:

    credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;


    Darren Liu (MSFT) | 刘嘉鸿 | Blog: http://blogs.msdn.com/b/darrenliu/
    • 已建议为答案 zhaoguijun 2012年4月20日 7:16
    2011年12月1日 7:10
    版主
  • IP 地址没有办法使用 AD 的验证。如果需要用 IP 地址, 请使用 UserName 和 Password 的验证。

    问题在:

    credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;


    Darren Liu (MSFT) | 刘嘉鸿 | Blog: http://blogs.msdn.com/b/darrenliu/

    你好,我试着使用了 UserName 和 Password 的验证,但我还是遇到一样的问题,希望能够得到大家的帮助。
    crm4.0学步
    2011年12月12日 15:44