Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an intranet application and it is accessible within company domain,but if someone want to access intranet application outside company than it will need to connect with VPN. So I want to check VPN connection status because if a user connect with VPN than we have some restriction in application.

What I have tried:

if (NetworkInterface.GetIsNetworkAvailable())
   {
       NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
       foreach (NetworkInterface Interface in interfaces)
       {

           if (Interface.OperationalStatus == OperationalStatus.Up)
           {

               if ((Interface.NetworkInterfaceType == NetworkInterfaceType.Ppp) && (Interface.NetworkInterfaceType != NetworkInterfaceType.Loopback))
               {
                   IPv4InterfaceStatistics statistics = Interface.GetIPv4Statistics();
                  MessageBox.Show(Interface.Name + " " + Interface.NetworkInterfaceType.ToString() + " " + Interface.Description);
               }
               else
               {
                   MessageBox.Show("VPN Connection is lost!");

                  // Perform some operation
               }
           }
       }
   }
Posted
Updated 25-Jun-17 1:36am

1 solution

It is not enough - and not correct - to say, that if there is an active VPN connection, the current web request should be limited...
By nature of the web it is very possible that some of the current request are coming from the domain and some from VPN...
As both standard domain users and VPN user would have an IP of your network it may be a problem to differentiate them...
As an example: in our office all workers has the opportunity to VPN into their own workstation, so when finally one browse the helpdesk application either from inside or outside, the application has no way to know it...
If the users are connected (via VPN) directly to your web server, than you can tell that the request's user address will be 'localhost' and limit, however I can see a lot of security problems by letting people VPN to your web server...
If all outsiders are connect to a known VPN machine (like terminal), then you can check the request's user address and see if it came from that machine, and limit possibilities...
So, you can not really tell if a request came from VPN or not, except in a specific network setup...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900