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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetUserName returns "SYSTEM"

GetUserName returns "SYSTEM"

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 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.
  • G Offline
    G Offline
    gothic_coder
    wrote on last edited by
    #1

    Hello All, I made a service which keep track of logon, logoff, lock and unlock notification.. I want to extract the logged on user name when user logged on, lock or unlock system.. So i'm using GetUserName in respective cases, but it returns me "SYSTEM" every time.. What could be the reason? Thanks...

    K D A 3 Replies Last reply
    0
    • G gothic_coder

      Hello All, I made a service which keep track of logon, logoff, lock and unlock notification.. I want to extract the logged on user name when user logged on, lock or unlock system.. So i'm using GetUserName in respective cases, but it returns me "SYSTEM" every time.. What could be the reason? Thanks...

      K Offline
      K Offline
      kakan
      wrote on last edited by
      #2

      Maybe because your service executes under the SYSTEM account?

      Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson

      1 Reply Last reply
      0
      • G gothic_coder

        Hello All, I made a service which keep track of logon, logoff, lock and unlock notification.. I want to extract the logged on user name when user logged on, lock or unlock system.. So i'm using GetUserName in respective cases, but it returns me "SYSTEM" every time.. What could be the reason? Thanks...

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Have you looked at the ISensLogon interface?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Man who follows car will be exhausted." - Confucius

        1 Reply Last reply
        0
        • G gothic_coder

          Hello All, I made a service which keep track of logon, logoff, lock and unlock notification.. I want to extract the logged on user name when user logged on, lock or unlock system.. So i'm using GetUserName in respective cases, but it returns me "SYSTEM" every time.. What could be the reason? Thanks...

          A Offline
          A Offline
          Anshul R
          wrote on last edited by
          #4

          Environment.UserName will return the current user name

          G 1 Reply Last reply
          0
          • A Anshul R

            Environment.UserName will return the current user name

            G Offline
            G Offline
            gothic_coder
            wrote on last edited by
            #5

            Thanks Everyone, I now used WTSQuerySessionInformationA :)

            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