0

正如我在标题中所说,我对 SecurityTokenRespone 有疑问。

IServiceManagement<IOrganizationService> serviceManagement = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("https://SERVICE_URI"));
AuthenticationCredentials authCreds = new AuthenticationCredentials();
authCreds.ClientCredentials.UserName.UserName = userName;
authCreds.ClientCredentials.UserName.Password = password;
AuthenticationCredentials tokenCreds = serviceManagement.Authenticate(authCreds);
SecurityTokenResponse securityToken = tokenCredentials.SecurityTokenResponse;

当我调用生产 CRM 时,我得到了 SecurityTokenRespone,但是当我调用我们的测试 CRM 时,SecurityTokenRespone 为空......

这是因为我们的生产 CRM 配置了 ADFS 而测试 CRM 没有配置吗?

如果是,是否可以通过某种方式绕过(我们的测试 CRM 位于无法暴露于互联网的域中)?

谢谢 :)

4

1 回答 1

1

我假设在您的测试 CRM 中,您只使用没有 ADFS 的普通 AD 登录。如果是,那么您将无法获得安全令牌,因为这里没有安全令牌。要获得组织服务,您可以:

ClientCredentials clientCreds = new ClientCredentials();
clientCreds.Windows.ClientCredential.UserName = "username";
clientCreds.Windows.ClientCredential.Password = "pass";
clientCreds.Windows.ClientCredential.Domain = "domain";
IServiceConfiguration<IOrganizationService> orgConfigInfo = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("http://yourcrmserver/CRO/XRMServices/2011/Organization.svc"));
OrganizationServiceProxy orgserv = new OrganizationServiceProxy(orgConfigInfo, clientCreds);
于 2017-10-03T09:57:04.090 回答