How use LogonUser ?

How use LogonUser ?

Post by schleed » Sat, 11 Sep 2004 22:23:50


i tried to run this code as normal user:

// Test der LogonUser Funktion
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <wchar.h>

HANDLE token=0;
BOOL ok;
int main(void)
ok = LogonUser("myadmin",".","mypwd",LOGON32_LOGON_INTERACTIVE,
&token );

if (ok == FALSE){ printf("ok = %d no LogonUser
else {printf("ok = %d\n",ok);}

return 0;
But i got ever the error 1314.
i tried to ad the privileg SeTcbPrivilege with Code from John side,but
it fails.
i tried before LogonUser() runs the Function NetUseAdd() to the \\IPC$
with success to get a token but LogonUser() ever fails.
Who can tell me why?



1. Using LogonUser with a LOCAL ACCOUNT which belongs to a remote machine.

2. Using LogonUser with the Guest account

I'm trying to write a plug-in for a ftp server of mine to permit the
integration with accounts defined on the Windows system.
What I basically need is impersonating a user, execute e filesystem
call (e.g. create a directory via os.mkdir()) and then switch back to
the original user (Administrator).
I wrote down this simple class in Python which seems to fit pretty
well with my purposes:

class WinNTAuthorizer:

def impersonate_user(self, username, password):
self.impersonated_user_handler = win32security.LogonUser(


def terminate_impersonation(self):

What I need now is impersonating the Guest user to handle the
anonymous logins (which it's exactly what IIS FTPd does) but I don't
know how to do it.
Does Guest account has a password or do I have to use something
different than LogonUser to manage it?
Could someone point me in the right direction?

Thanks in advance.

--- Giampaolo

3. Using LogonUser API in with an account other than ASPNet account

4. Using LogonUser to authenticate a user

5. Using LogonUser with the Guest account

6. problem with impersonation using LogonUser

7. Windows forms security using logonuser API

8. Using the LogonUser API

9. LogonUser/impersonate user using Kerberos ticket

10. LogonUser call on remote computer using SmartCard

11. LogonUser() with default provider uses NTLM

12. Fwd: DMO & ADO connections fail even with valid credentials when using LOGON32_LOGON_NEW_CREDENTIALS flag with 'LogonUser'

13. Using the LogonUser API

14. Can't copy/rename file using CreateProcessWithLogonW, ImpersonateLoggedOnUser and LogonUser

15. DMO & ADO connections fail even with valid credentials when using LOGON32_LOGON_NEW_CREDENTIALS flag with 'LogonUser'