title: Windows and Detecting Captive Portals
body: <p>Trying to detect when a Captive Portal is in use on a internet connection i.e a laptop connected at a coffee shop.</p>
  
  <p>Trying to achieve this using the Network List Manager COM Object:</p>
  
  <pre><code>NETWORKLIST.NetworkListManager _networkListManager = new NetworkListManager();
  foreach (INetworkConnection net in _networkListManager.GetNetworkConnections())
  {                
      if (net.GetConnectivity().HasFlag(NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_INTERNET) == true)
        {
             // Check if we are connected by a captive web portal
             // using NLM_INTERNET_CONNECTIVITY_WEBHIJACK
        }                                
   }
  </code></pre>
  
  <p>According to the documentation here: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa370750(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/aa370750(v=vs.85).aspx</a></p>
  
  <p>"These connectivity flags can be retrieved by querying for the NA_InternetConnectivityV4 or NA_InternetConnectivityV6 properties using the IPropertyBag interface for an INetwork or INetworkConnection interface"</p>
  
  <p>I appears that the NA_InternetConnectivityV4 enumerations are not present (incomplete implementation) or I don't know how to work with them.</p>
  
  <p>Has anyone actually used this or have ideas on ways to detect when a captive portal is in use?</p>