Can I disable the login prompt for MS CRM 2011 SDK if credentials are wrong?

帅比萌擦擦* 提交于 2019-12-05 05:29:56

问题


Right now I access the CRM SDK as follows

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
}

However, if the domain credentials are incorrect, a Windows login prompt appears (somewhere in service.Execute). I don't want that login prompt. I have worked around this issue by validating the credentials using PrincipalContext before passing them to the DiscoveryServiceProxy, but I'm not entirely happy with that.

Is there a way to disable the login prompt?


回答1:


Someone on the CRM forums told me what to do:

credentials.ClientCredentials.SupportInteractive = false;



来源:https://stackoverflow.com/questions/14646645/can-i-disable-the-login-prompt-for-ms-crm-2011-sdk-if-credentials-are-wrong

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!