title: Programmatically setup a PEAP connection in Windows Mobile
body: <p>I have been working on this for a few days and this is doing my head in:</p>
  
  <p>Our application is built using the .NET Compact Framework 2.0 and running on Windows Mobile 5 &amp; 6 devices. 
  We can set the WLAN connection of the device programmatically using the Wireless Zero Config functions (described here: msdn.microsoft.com/en-us/library/ms894771.aspx), most notably the WZCSetInterface function which we pinvoke from our application. This works fine for WEP and WPA-PSK connections. </p>
  
  <p>In a recent effort to add support for WPA2 networks we decided to modify the code. We have successfully added support for WPA2 which uses a certificate for the 802.1x authentication by setting the correct registry settings before calling WZCSetInterface.
  Now we want to do the same for WPA2 using PEAP (MS-CHAPv2) authentication. When manually creating such a connection in Windows Mobile the user will be prompted to enter the domain/user/password details. In our application we will have those details stored locally and want to do this all programmatically without any user intervention.</p>
  
  <p>So I thought going along the same route as the certificate authentication, setting the correct registry entries before calling WZCSetInterface.</p>
  
  <p>The registry settings we set are:
  \HKCU\Comm\EAP\Config\[ssid name]</p>
  
  <ul>
  <li>Enable8021x = 1 (DWORD)  </li>
  <li>LastAuthSuccessful = 1 (DWORD)  </li>
  <li>EapTypeId = 25 (DWORD)   </li>
  <li>Identity = "domain\username" (string)   </li>
  <li>Password = binary blob containing the password that is encrypted using the<br>
  CryptProtectData function (described here: msdn.microsoft.com/en-us/library/ms938309.aspx)</li>
  </ul>
  
  <p>But when these settings are set and I call WZCSetInterface with the correct parameters, it still prompts me with the User Logon dialog asking for the domain/username/password.</p>
  
  <p>Has anyone got an idea what I need to do to prevent the password dialog from appearing and connect straight away with the settings stored in the registry?</p>