Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim old As WindowsIdentity = WindowsIdentity.GetCurrent
Dim token As System.IntPtr
Dim jos As WindowsIdentity
If LogonUser("Tuur", System.Environment.MachineName, "blablabla", _
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token) Then
jos = New WindowsIdentity(token)
End If
End Sub
Private Declare Auto Function LogonUser Lib "advapi32.dll" ( _
ByVal lpszUsername As String, _
ByVal lpszDomain As String, _
ByVal lpszPassword As String, _
ByVal dwLogonType As Integer, _
ByVal dwLogonProvider As Integer, _
ByRef phToken As IntPtr) As Boolean
Const LOGON32_LOGON_INTERACTIVE As Long = 2
Const LOGON32_PROVIDER_DEFAULT As Long = 0