There was a question in the forums, if there is a way to configure a network adapter automatically - without an user interaction. Using the UI, the user may select "My network card connects to" value for every adapter in the adapters list. It may be changed to point one of the available network destinations like "The Internet" , "Work", etc. So, is there a way to this automatically?
In short the answer is YES! There is a way. We may prepare an OMA Client Provisioning File and pass it to the appropriate configuration provider in Windows Mobile.
An appropriate configuration file would be like this:
<wap-provisioningdoc>
<characteristic type="CM_NetEntries">
<characteristic type="Adapter Name">
<parm name="DestId" value="{A1182988-0D73-439e-87AD-2A5B369F808B}"/>
<parm name="Adapter" value="Qualified Name"/>
</characteristic>
</characteristic>
</wap-provisioningdoc>
This file will bind a network adapter named "Adapter Name"
to the "Work" destination. We have to change the "Adapter Name" value with
the name of the adapter as it is seen in the adapters list. The "Qualified Name" should be changed with the fully qualified name of the adapter - it may be obtained by using the
GetAdaptersAddresses routine
If we want to change the destination to "The Internet" , we have to supply different GUID for the DestId parameter. Following network identifiers as configured by default on Windows Mobile:
The Internet: {436EF144-B4FB-4863-A041-8F905A62C572}
Work: {A1182988-0D73-439e-87AD-2A5B369F808B}
WAP Network: {7022E968-5A97-4051-BC1C-C578E2FBA5D9}
Secure WAP Network:{F28D1F74-72BE-4394-A4A7-4E296219390C}
CurrentDTPTNetwork:{A1182988-0D73-439e-87AD-2A5B369F808B}
What we have to do in order to apply this configuration setting?
We have the following options:
1. Preparing the provisioning Xml file , save it as _setup.xml, and place it inside a CAB file. We may "execute" the file on the device, then. Check out this
post for details about deploying provisioning files with CABs.
2. We may apply these settings through code(Compact Framework) by using the managed Microsoft.WindowsMobile.Configuration.ConfigurationManager class from Windows Mobile 5 SDK:
string configurationXml = "<wap-provisioningdoc><characteristic type=\"CM_NetEntries\">"+
"<characteristic type=\"Adapter Name\"><parm name=\"DestId\" "+
"value=\"{A1182988-0D73-439e-87AD-2A5B369F808B}\"/><parm name=\"Adapter\" value=\"Qualified Name\" /> "+
"</characteristic></characteristic></wap-provisioningdoc>";
// Load XML
XmlDocument configurationXmlDoc = new XmlDocument();
configurationXmlDoc.LoadXml(configurationXml);
// Send to Configuration Manager
ConfigurationManager.ProcessConfiguration(configurationXmlDoc, false);
Also the unmanaged version
DMProcessConfigXML may be used
Check out
this post for unmanaged wrapper of DMProcessConfigXML
LinksCM_NetEntries Configuration Service Provider Examples for OMA Client ProvisioningInjecting Provisioning XML into a cab using VS 2005 on the Windows Mobile BlogDMProcessConfigXML on the Marcus Perryman's WebLogWindows Mobile Device Management for more configuration options