我们正试图为我们的BYOD用户创建一个应用程序,让他们轻松地连接到我们的802.1x网络。
我在网上找到了以下代码:
Imports System.Runtime.InteropServices
Module Module1
Private _stringToHex As Object
Private Property Ret As UInteger
Private Property StringToHex(profileName As String) As Object
Get
Return _stringToHex
End Get
Set(value As Object)
_stringToHex = value
End Set
End Property
Private Property handle As IntPtr
Private Property Guid As Guid
<DllImport("Wlanapi", EntryPoint:="WlanSetProfileEapXmlUserData")> _
Public Function WlanSetProfileEapXmlUserData(<[In]()> ByVal hClientHandle As IntPtr, _
<[In](), MarshalAs(UnmanagedType.LPStruct)> ByVal interfaceGuid As Guid, _
<[In](), MarshalAs(UnmanagedType.LPWStr)> ByVal strProfileName As String, _
<[In]()> ByVal flags As ULong, _
<[In](), MarshalAs(UnmanagedType.LPWStr)> ByVal profileXml As String, _
<[In]()> ByVal pReserved As IntPtr) As UInteger
End Function
Sub Main()
Dim profileName As String = "ISL"
Dim AuthXml As String = String.Format("<?xml version=""1.0"" ?>" & _
"<EapHostUserCredentials xmlns=""http://www.microsoft.com/provisioning/EapHostUserCredentials"" xmlns:eapCommon=""http://www.microsoft.com/provisioning/EapCommon"" xmlns:baseEap=""http://www.microsoft.com/provisioning/BaseEapMethodUserCredentials"">" & _
"<EapMethod>" & _
"<eapCommon:Type>25</eapCommon:Type>" & _
"<eapCommon:AuthorId>0</eapCommon:AuthorId>" & _
"</EapMethod>" & _
"<Credentials xmlns:eapUser=""http://www.microsoft.com/provisioning/EapUserPropertiesV1"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:baseEap=""http://www.microsoft.com/provisioning/BaseEapUserPropertiesV1"" xmlns:MsPeap=""http://www.microsoft.com/provisioning/MsPeapUserPropertiesV1"" xmlns:MsChapV2=""http://www.microsoft.com/provisioning/MsChapV2UserPropertiesV1"">" & _
"<baseEap:Eap>" & _
"<baseEap:Type>25</baseEap:Type>" & _
"<MsPeap:EapType>" & _
"<MsPeap:RoutingIdentity>username</MsPeap:RoutingIdentity>" & _
"<baseEap:Eap>" & _
"<baseEap:Type>26</baseEap:Type>" & _
"<MsChapV2:EapType>" & _
"<MsChapV2:Username>USERNAME</MsChapV2:Username>" & _
"<MsChapV2:Password>PASSWORD</MsChapV2:Password>" & _
"<MsChapV2:LogonDomain>DOMAIN</MsChapV2:LogonDomain>" & _
"</MsChapV2:EapType>" & _
"</baseEap:Eap>" & _
"</MsPeap:EapType>" & _
"</baseEap:Eap>" & _
"</Credentials>" & _
"</EapHostUserCredentials>", profileName, StringToHex(profileName))
Ret = WlanSetProfileEapXmlUserData(handle, Guid, profileName, Convert.ToUInt64(&H1), AuthXml, IntPtr.Zero)
End Sub
End Module这给了我以下错误:“附加信息:对'test_wlan_conf!test_wlan_conf.Module1::WlanSetProfileEapXmlUserData‘函数的调用不平衡堆栈。这可能是因为托管PInvoke签名与非托管目标签名不匹配。检查PInvoke签名的调用约定和参数是否与目标非托管签名匹配。”
以我几乎不存在的.net技能,我承认这对我来说真的很难解决。任何帮助都将不胜感激!
发布于 2015-06-16 14:30:15
使用论坛上的AutoIT UDF自己解决了这个问题。UDF调用wlanapi.dll并允许使用其功能配置无线局域网接入、配置文件等。
Windows 7的步骤如下:
Windows 8的步骤如下:
希望这能有所帮助
https://stackoverflow.com/questions/30845107
复制相似问题