How to set an open network profile

Mar 11, 2009 at 9:07 AM
Hi:
  I have successfully set the profile for network using WEP. However,I failed to set a profile for open network.I try to get the xml file by calling GetProfileXml() and write xml just the same as the result. But it doesn't work. Can somebody show me the xml file format of the open network profile?
Mar 12, 2009 at 10:00 AM
Hi,
are you sure you got an existing profile?
for the very first connection I had to write a complete profile :

                                StringBuilder xmlProfileString = new StringBuilder(100);
                                XmlWriterSettings settings = new XmlWriterSettings();
                                settings.Indent = true;
                                settings.NewLineOnAttributes = true;

                                XmlWriter writer = XmlWriter.Create(xmlProfileString, settings);
                                writer.WriteStartElement("WLANProfile", @"http://www.microsoft.com/networking/WLAN/profile/v1");
                                writer.WriteElementString("name", networkName);
                                writer.WriteStartElement("SSIDConfig");
                                writer.WriteStartElement("SSID");
                                string tmp = copySSIDtoString(n.dot11Ssid); //"44656D6F3347";
                                writer.WriteElementString("hex", tmp); //copySSIDtoString(n.dot11Ssid));
                                writer.WriteElementString("name", convertSSIDtoString(n.dot11Ssid));
                                writer.WriteEndElement();
                                writer.WriteEndElement();
                                // hard to find an "ESS" value somewhere in the API...
                                writer.WriteElementString("connectionType", "ESS"); // connection type = Infrastructure
                                writer.WriteStartElement("MSM");
                                writer.WriteStartElement("security");
                                writer.WriteStartElement("authEncryption");
                                writer.WriteElementString("authentication", "open");
                                writer.WriteElementString("encryption", "none");
                                writer.WriteElementString("useOneX", "false");
                                writer.WriteEndElement();
                                writer.WriteEndElement();
                                writer.WriteEndElement();
                                writer.Close();
                                xmlProfile = xmlProfileString.ToString();
                                i.SetProfile(Wlan.WlanProfileFlags.AllUser, xmlProfile, true);
                                i.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, networkName);

hope that helps,
carole

Mar 12, 2009 at 10:06 AM
Hi again,

I remember now I had first to connect to the network I wanted, using the software provided by the Wifi interface. This is in order to get an existing profile for this network programmatically, and then to be able to re-create one for first connections (with no profile created yet).
I'm not sure I'm clear...
carole