简体   繁体   English

如何使用Windows登录凭据进行代理身份验证使用C#

[英]how to use the windows login credentials for proxy authentication using C#

Is it possbile to use the windows login credential for proxy authentication using C#. 是否可以使用Windows登录凭证进行使用C#进行代理身份验证。

I have a facebook application, which calls the facebook methods. 我有一个facebook应用程序,它调用facebook方法。 During every facebook call, it gives an error "407: proxy authentication required" 在每次facebook通话期间,它都会出现错误“407:需要代理身份验证”

The following code will allow the user to set the proxy :- 以下代码将允许用户设置代理: -

WebProxy oWebProxy = new System.Net.WebProxy(ProxyServer, ProxyPort);       
oWebProxy.Credentials = new NetworkCredential(ProxyUser,ProxyPassword,ProxyDomain);
oserv.Proxy = oWebProxy; 
oserv.Credentials = new NetworkCredential(theusername, thepassword); 

But, is there any other way of doing the same thing without hardcoding my company's login credentials. 但是,如果不对我公司的登录凭据进行硬编码,是否还有其他方法可以做同样的事情。

You can use : 您可以使用 :

oWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

If it still does not solve your problem, then please refer to the site : http://support.microsoft.com/kb/813834 如果它仍然无法解决您的问题,请访问该网站: http//support.microsoft.com/kb/813834

Try creating a WebProxy with a default constructor (don't supply the proxy server) and see if it works for you.. 尝试使用默认构造函数创建WebProxy(不提供代理服务器),看看它是否适合您。

WebProxy oWebProxy = new System.Net.WebProxy();

The default constructor will take the credentials from the system as you entered them in your web browser.. 当您在Web浏览器中输入凭据时,默认构造函数将从系统获取凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用C#使用具有不同凭据的Windows身份验证连接到数据库 - Connecting To A Database Using Windows Authentication With Different Credentials using C# C# Selenium - 如何使用带身份验证的代理? - C# Selenium - How to use proxy with Authentication? 如何将 C# HTTPClient 与 Windows 凭证一起使用 - How to use C# HTTPClient with Windows Credentials 如何在“ Windows身份验证对话框”上应用自动化并使用c#,Selenium Webdriver登录到Web应用程序 - How to apply automation on “Windows authentication dialog” and login into the web application using c# , selenium webdriver 如何使用C#在Windows上存储和检索凭据 - How to store and retrieve credentials on Windows using C# C#应用程序-使用Windows用户凭据对oracle数据库登录进行身份验证 - C# application - authenticate oracle database login using windows user credentials 使用Wininet的C#代理身份验证 - c# proxy authentication using wininet C#-使用该Windows凭据对话框登录 - C# - Log In By Using That Windows Credentials Dialog 在C#中设置代理凭据后,为什么会收到“需要代理身份验证”的信息 - Why do I get 'Proxy Authentication Required'when I've set up proxy credentials in c# C#Windows服务在登录时输入用户凭据 - c# windows service enter user credentials at login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM