Click here to Skip to main content
13,897,313 members
Rate this:
 
Please Sign up or sign in to vote.
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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...
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web03 | 2.8.190306.1 | Last Updated 25 Jun 2017
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100