How to find Logged In user type in C/C++?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • santusapi
    New Member
    • Mar 2010
    • 26

    How to find Logged In user type in C/C++?

    Hello All,
    Please can anybody help me how to find the system user type in c/c++ code...? I just want to do some operation if the user is system admin... If there is some other way to find system admin, please tell me and help me in solving this...
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    There is no way to do it in standard C/C++ you would need to call some platform dependant OS provided API if there is one.

    Comment

    • santusapi
      New Member
      • Mar 2010
      • 26

      #3
      Thank You Banfa... But can you help me a little more in doing this...??? Please...

      Comment

      • hype261
        New Member
        • Apr 2010
        • 207

        #4
        What OS are you using snatusapi? That will help us give you a clue...

        Comment

        • santusapi
          New Member
          • Mar 2010
          • 26

          #5
          I'm using windows XP.. but i might use that call in most of the versions of windows...

          Comment

          • newb16
            Contributor
            • Jul 2008
            • 687

            #6
            It may not matter who is logged in, but what under user your process is running.
            Find the user the process is running under and then find if it belongs to administrators group? Then search for functions to do this on microsoft site, starting e.g. from here http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx
            Googled a bit more ... -
            OpenProcess (PID) -> process handle
            OpenProcessToke n (process handle) -> access token
            GetTokenInforma tion (access token) -> token info
            LookupAccountSi d (token info.SID) -> "domain\use r"

            Comment

            • santusapi
              New Member
              • Mar 2010
              • 26

              #7
              Thank you newb16... I will try this once... Thanks a lot for the idea...

              Comment

              Working...