【问题标题】:IFD/ADFS connection errors in WCF service to CRM 2011WCF 服务中的 IFD/ADFS 连接错误到 CRM 2011
【发布时间】:2014-01-24 09:47:48
【问题描述】:

我目前正在尝试找出失败的原因。

这是我在 WCF 服务之间构建连接组织 Web 服务的对象的方式。部署是 IFD/ADFS

    string uname = WebConfigurationManager.AppSettings["uname"];
    string password = WebConfigurationManager.AppSettings["password"];
    //string domain = WebConfigurationManager.AppSettings["domain"];

    //Construct connection objects
    Uri _organizationUri = new Uri(WebConfigurationManager.AppSettings["url"]);
    Uri _homeRealmUri = null;
    ClientCredentials _credentials = new ClientCredentials();

    OrganizationServiceProxy _orgProxy; 
    IOrganizationService _service;

    IServiceConfiguration<IOrganizationService> config;

    //Initialize connection objects
    public void init()
    {
        _credentials.Windows.ClientCredential = new System.Net.NetworkCredential(uname, password);

        config = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(_organizationUri);

        _orgProxy = new OrganizationServiceProxy(config, _credentials);
        //_orgProxy = new OrganizationServiceProxy(_organizationUri, _homeRealmUri, _credentials, null);
        _service = (IOrganizationService)_orgProxy;

    }

尝试检索(或通过 _service 的任何其他功能)

LeadEntity = _service.Retrieve("lead", leadID, new ColumnSet(true));

给我一​​个错误提示“登录尝试失败!”

然后我做了一些谷歌搜索,发现有人建议输入这样的域,例如 uname@domain。这会将错误更改为:

与目标“https://adfstst.xyxy.com/adfs/services/trust/13/kerberosmixed”的“https://adfstst.xyxy.com/adfs/services/trust/13/kerberosmixed”的 SOAP 安全协商失败。有关详细信息,请参阅内部异常

内部异常是这样说的:

初始化安全内容失败。确保服务主体名称正确。

任何关于如何修复连接的建议将不胜感激。

【问题讨论】:

标签: c# wcf dynamics-crm-2011 adfs


【解决方案1】:

尝试使用以下代码:

public void init()
{
    _credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
    _credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
    _credentials.UserName.UserName = uname;
    _credentials.UserName.Password = password;

    IOrganizationService service = new OrganizationServiceProxy(new Uri(_organizationUri), null, credentials, null);
}

【讨论】:

  • 这两行代码在上面的例子中似乎没有任何贡献:_credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; _credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-05
相关资源
最近更新 更多