LogonUser?
-
any body could tell the correct perameters of logonuser function? i am having a simple network of two computers and no domain i simple need passworad and user name to enter. My service is running on one computer where i want to login and i want to login to the system using logonuser api or function but i could not successed yet. plz tell mee correct parameters of it?
BOOL LogonUser( LPTSTR lpszUsername, LPTSTR lpszDomain, LPTSTR lpszPassword, DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken );
-
any body could tell the correct perameters of logonuser function? i am having a simple network of two computers and no domain i simple need passworad and user name to enter. My service is running on one computer where i want to login and i want to login to the system using logonuser api or function but i could not successed yet. plz tell mee correct parameters of it?
BOOL LogonUser( LPTSTR lpszUsername, LPTSTR lpszDomain, LPTSTR lpszPassword, DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken );
Notice this: The LogonUser function attempts to log a user on to the local computer. (LogonUser[^]) If you're trying to do that over the network, it won't work. You could use OpenSCManager()[^] to open the SCM on the remote machine, then use the other Service Functions[^] to do things with the services on that machine.
"The greatest danger to humanity is humanity without an open mind."
- Ian Mariano - http://www.ian-space.com/ -
any body could tell the correct perameters of logonuser function? i am having a simple network of two computers and no domain i simple need passworad and user name to enter. My service is running on one computer where i want to login and i want to login to the system using logonuser api or function but i could not successed yet. plz tell mee correct parameters of it?
BOOL LogonUser( LPTSTR lpszUsername, LPTSTR lpszDomain, LPTSTR lpszPassword, DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken );
Some years ago I made this sample program:
main (int argc, char **argv) { BOOL Successful; HANDLE AccessToken; DWORD ErrorCode; char *BufferPtr; Successful = LogonUser (argv[1], ".", argv[2], LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, &AccessToken); printf ("LogonUser -> %d\n", Successful); if (!Successful) { ErrorCode = GetLastError(); printf ("GetLastError -> %d\n",ErrorCode); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, ErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &BufferPtr, 0, NULL ); printf ("Error String -> %s\n",BufferPtr); free (BufferPtr); } }
However, you should have a certain privilege before you can do this (I can't remember anymore which one it was). Othwerwise you get the following error:LogonUser -> 0 GetLastError -> 1314 Error String -> A required privilege is not held by the client.
Hope this helps. Enjoy life, this is not a rehearsal !!! -
any body could tell the correct perameters of logonuser function? i am having a simple network of two computers and no domain i simple need passworad and user name to enter. My service is running on one computer where i want to login and i want to login to the system using logonuser api or function but i could not successed yet. plz tell mee correct parameters of it?
BOOL LogonUser( LPTSTR lpszUsername, LPTSTR lpszDomain, LPTSTR lpszPassword, DWORD dwLogonType, DWORD dwLogonProvider, PHANDLE phToken );
- What is the result of GetLastError()? 2) What OS version, SP you are using? The most common mistake using LogonUser() is that it needs SE_TCB_PRIVILEGE on pre-XP systems. This privilege is (and should be!) granted only to the SYSTEM account, which means that actually only service processes are able to perform a LogonUser() -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )
-
- What is the result of GetLastError()? 2) What OS version, SP you are using? The most common mistake using LogonUser() is that it needs SE_TCB_PRIVILEGE on pre-XP systems. This privilege is (and should be!) granted only to the SYSTEM account, which means that actually only service processes are able to perform a LogonUser() -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )
You learn something every day. I didn't realize that XP removed the SE_TCBNAME privilege requirement from LogonUser. -------- There are 10 types of people in this world. Those who know binary and those who don't.