I need in a Windowsapplication the access to a file that is on a Fileserver.
Only the administrator has access to the directory of the file.
My App needs to open this file. In ASP.net I can Impersonate the user, but
it doesn't work in a Windows App.
I tried to change the Principal of the thread but it doesn't work.
The Script is:
....
Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
Dim LOGON32_LOGON_NETWORK As Integer = 3 'tried both
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0
Dim token As IntPtr
Dim WI As System.Security.Principal.WindowsIdentity
If LogonUser("administrator", "mydom", "password",
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
'Logonuser from API advapi32.dll
WI = New System.Security.Principal.WindowsIdentity(token) 'that works
End If
Dim WP As New System.Security.Principal.WindowsPrincipal(WI) 'that
works
'System.Threading.Thread.CurrentThread.CurrentPrin cipal = WP
Dim NeuerThread As New Threading.Thread(AddressOf newSub)
NeuerThread.CurrentPrincipal = WP 'that works
NeuerThread.Start()
....
' in newSub was tried to get access to that file but it doesn't work
has anybody an idea whats wrong or an solution for this problem?
Thanks a lot Thomas