Hello,
In this example , they use the winapi function LogonUser for logging on and obtaining the token of a windows user. But i don't like that in my vb.net program. Is it possible to obtain the token of a windows user in a more .Net way?
thx,
Tuur
This is how my code looks like:
VB Code:
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


Reply With Quote


