How to Configure Automatic Network Domain Authentication & Proxy in C#

By Ashish Yadav → Saturday, May 10, 2014
In this Corporate world Mobility & Security is very important aspect and there comes to picture Authentication Systems, Logon's, Firewalls, etc.. So as to make centralized Authentication we have many solutions available in market, One of the most famous authentication system is Microsoft's Active Directory-LDAP


Mostly all the organizations use Firewall/Proxy and even to use internet User Authentication is required. This can be a very difficult problem when you are a developer and you need to use Internet which is behind some firewall/proxy and on top of it required authentication as well.

So If you are using a windows system which is using Active Directory Authentication & 99% organizations use the same authentication for Internet as well which is behind firewall/proxy. The below piece of code can help you to automatically handle user authentication for internet & proxy configuration whatever is configured in Internet Explorer by default. Thus developed application can be tested and deployed on any network/organization without any configuration change.

//This line of code automatically detects the system configured proxy. i.e the proxy setting  configured in Internet explorer will be used when communicated with Internet. 

IWebProxy proxy = WebRequest.GetSystemWebProxy(); 

//This line of code fetched and logs on to the system using Authentication Credentials from cache.

proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; 
request.Proxy = proxy;
Thus using the above code can help you to fix Proxy settings & Authentication Configuration handling when developing an application on C#
Ashish Yadav

I'm Ashish. BE - Computers by education, Big Data Analyst and Software developer by profession, Ethical hacker by passion. Technology freak, Loves blogging, reading and talking.

No Comment to " How to Configure Automatic Network Domain Authentication & Proxy in C# "