Re: Impersonation

From: Nadia (nadgiusti_at_libero.it)
Date: 05/28/03


Date: Wed, 28 May 2003 21:51:13 +0200


Take a look also at
http://www.codeproject.com/csharp/cpimpersonation1.asp?target=impersonation
this code woks at Windows 2000, and XP (but won't work on 98 and ME becouse
they don't use user tokens)
I hope this help you
by
nadia

"GeoffOs" <NOSPAM@NOSPAM.com> wrote in message
news:OSbhkBJGDHA.3604@tk2msftngp13.phx.gbl...
> 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
>
>



Relevant Pages

  • Re: LoadLibraryEx (as datafile) and MorIcons.dll - extracting icons
    ... >> Immediately after the failing LoadLibraryEx() call, call GetLastError() ... > resources in files that Windows offers in a default install ... ... > Any idea what I can do to access resources in NE-style executables (DLL's, ...
    (microsoft.public.win32.programmer.tools)
  • Re: DeviceIoControl W2K
    ... ich habe den Fehlercode mit GetLastError abgefragt. ... Hierbei wird die Variable C mit dem Fehlercode 50 belegt. ... > in der Device Input and Output Control Reference des Platform SDK befindet ... Requires Windows XP, Windows 2000 Professional, Windows NT ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: How to Validate User Credentials on Windows 2000 OS?
    ... GetLastError() return = %d", ... "Alex Fedotov" wrote: ... still I am unable to verify user Credentials on Windows 2000. ... Can some one provide me code snippets which uses LogonUserAPI on ...
    (microsoft.public.platformsdk.security)
  • Re: fopen - strange behavior
    ... you might try GetLastError() since fopen must call CreateFile under ... and CreateFile would call SetLastError on failure. ... I think I'll try to rewrite it for Windows CE ... Mateusz Łoskot ...
    (microsoft.public.pocketpc.developer)

Loading