现在我访问CRM SDK如下
IServiceManagement<IDiscoveryService> serviceManagement =
ServiceConfigurationFactory.CreateManagement<IDiscoveryService>(discoveryUri);
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(userName, password, domain);
using (DiscoveryServiceProxy serviceProxy = new DiscoveryServiceProxy(new DiscoveryServiceProxy(serviceManagement, credentials))
{
RetrieveOrganizationsRequest orgRequest = new RetrieveOrganizationsRequest();
RetrieveOrganizationsResponse orgResponse =
(RetrieveOrganizationsResponse)service.Execute(orgRequest);
// do something with organisations
}
但是,如果域凭据不正确,则会出现Windows登录提示(在 中的某处service.Execute
)。我不想要那个登录提示。我通过在将凭据PrincipalContext
传递给之前使用验证凭据来解决此问题DiscoveryServiceProxy
,但我对此并不完全满意。
有没有办法禁用登录提示?