我在我的 CRM 实例上配置了基于声明的身份验证。我正在使用自定义 STS(此处提供示例) 现在我想从一些测试应用程序访问 Web 服务。有没有人有这方面的例子?在 Windows 身份验证的情况下,我尝试使用相同的代码进行连接。但是,当然,不成功。我收到一个错误:
{“在配置的安全令牌服务上找不到身份验证端点 Kerberos!”}
这是连接代码(用于 AD 身份验证类型):
OrganizationServiceProxy orgserv;
ClientCredentials clientCreds = new ClientCredentials();
ClientCredentials devCreds = new ClientCredentials();
clientCreds.Windows.ClientCredential.UserName = "user";
clientCreds.Windows.ClientCredential.Password = "P@$$w0rd";
clientCreds.Windows.ClientCredential.Domain = "myDomain";
IServiceConfiguration<IOrganizationService> orgConfigInfo =
ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("https://myCRMServer/myOrg/XRMServices/2011/Organization.svc"));
using (orgserv = new OrganizationServiceProxy(orgConfigInfo, clientCreds))
{
orgserv.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
orgserv.EnableProxyTypes();
connection = orgserv;
}
我在某处发现基于声明的身份验证足以仅发送 UPN(用户主体名称)。但同样的错误也会发生。我也尝试过使用用户名/密码组合,但没有成功。
AuthenticationCredentials authCredentials = new AuthenticationCredentials();
...
authCredentials.UserPrincipalName = "user";
...
authCredentials.ClientCredentials.UserName.UserName = _userName;
authCredentials.ClientCredentials.UserName.Password = _password;
之后的错误是:The authentication endpoint Username was not found on the configured Secure Token Service!