Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. LogonUser?

LogonUser?

Scheduled Pinned Locked Moved C / C++ / MFC
comsysadminjsonquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imran_rafique
    wrote on last edited by
    #1

    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
    );
    

    r00d0034@yahoo.com

    I P D 3 Replies Last reply
    0
    • I imran_rafique

      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
      );
      

      r00d0034@yahoo.com

      I Offline
      I Offline
      ian mariano
      wrote on last edited by
      #2

      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/

      1 Reply Last reply
      0
      • I imran_rafique

        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
        );
        

        r00d0034@yahoo.com

        P Offline
        P Offline
        Patje
        wrote on last edited by
        #3

        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 !!!

        1 Reply Last reply
        0
        • I imran_rafique

          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
          );
          

          r00d0034@yahoo.com

          D Offline
          D Offline
          Daniel Lohmann
          wrote on last edited by
          #4
          1. 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 )
          J 1 Reply Last reply
          0
          • D Daniel Lohmann
            1. 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 )
            J Offline
            J Offline
            JT Anderson
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups