我目前正在试图找出失败的原因。
以下是我如何在WCF服务之间构建用于连接组织webservice的对象。部署是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安全协商失败。有关详细信息,请参阅内部异常
内部异常说明了这一点:
InitializeSecurityContent失败。确保服务主体名称正确。
有关如何修复连接的任何建议都将不胜感激。
答案 0 :(得分:0)
尝试使用以下代码:
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);
}