Impersonation
From: GeoffOs (NOSPAM_at_NOSPAM.com)
Date: 05/12/03
- Next message: Sparky: "aximp error"
- Previous message: Michel Gallant \(MVP\): "Re: How to determine which permission is being requested?"
- Next in thread: Shel Blauman [MSFT]: "Re: Impersonation"
- Reply: Shel Blauman [MSFT]: "Re: Impersonation"
- Reply: Nadia: "Re: Impersonation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 12 May 2003 15:12:24 +0100
I have a windows server that requires access to the file system at certain
times. I though the best way to implement this was to use impersonation.
I have picked up the code from MSDN and it never returns a token value. (see
code below)
I am currently working on Win2K so I have changed the dwLogonProvider to
LOGON32_PROVIDER_WINNT50 (1 instead of 0) so that it will work on my dev
machine plus win2k servers. From the code below I always hit the Error Code.
When I changed the code for the dwLogonProvider from 0 to 1 the error code
changed from to 5. From lookups on MSDN the errors are
5 Error Access Denied
1214 Error Provilige not held
Error 5 is a bit strange as i am a member of the local administrator group.
Can anyone help.
Dim loggedOn As Boolean = LogonUser(Me.txtUserName.Text, Me.txtDOMAIN.Text,
Me.txtPassword.Text, 3, 1, token1)
txtLog.AppendText("LogonUser called" + vbCrLf)
'Call GetLastError to try to determine why logon failed if it did not
succeed.
Dim ret As Integer = GetLastError()
txtLog.AppendText("LogonUser Success? " + loggedOn.ToString() + vbCrLf)
txtLog.AppendText("NT Token Value: " + token1.ToString() + vbCrLf)
If ret <> 0 Then
ret = System.Runtime.InteropServices.Marshal.GetLastWin32Error()
txtLog.AppendText("Error code (126 == ""Specified module could not be
found""): " + ret.ToString() + vbCrLf)
Exit Sub
End If
- Next message: Sparky: "aximp error"
- Previous message: Michel Gallant \(MVP\): "Re: How to determine which permission is being requested?"
- Next in thread: Shel Blauman [MSFT]: "Re: Impersonation"
- Reply: Shel Blauman [MSFT]: "Re: Impersonation"
- Reply: Nadia: "Re: Impersonation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]