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#
  4. windows service username

windows service username

Scheduled Pinned Locked Moved C#
securityquestion
4 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.
  • T Offline
    T Offline
    tomorrow_ft
    wrote on last edited by
    #1

    hi all, normally in win app. or web app. I can take windows log on username with this code "System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();" but with windows service I can't do this, it takes like this: "NT AUTHORITY\SYSTEM" Howcan I do this with windows service?? thanks..

    C E M 3 Replies Last reply
    0
    • T tomorrow_ft

      hi all, normally in win app. or web app. I can take windows log on username with this code "System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();" but with windows service I can't do this, it takes like this: "NT AUTHORITY\SYSTEM" Howcan I do this with windows service?? thanks..

      C Offline
      C Offline
      Calla
      wrote on last edited by
      #2

      What account have you defined it to run under? Seems like Local System..

      1 Reply Last reply
      0
      • T tomorrow_ft

        hi all, normally in win app. or web app. I can take windows log on username with this code "System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();" but with windows service I can't do this, it takes like this: "NT AUTHORITY\SYSTEM" Howcan I do this with windows service?? thanks..

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        Go to your control panel-Admin Tools-Services and right click on the service, select properties -Log On tab ... have fun. BTW,

        System.Security.Principal.WindowsIdentity.GetCurrent().Name

        is a string. If you call ToString on a string you look foolish. It is my personal crusade to get .NET developers to understand the concept of type.

        Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

        1 Reply Last reply
        0
        • T tomorrow_ft

          hi all, normally in win app. or web app. I can take windows log on username with this code "System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();" but with windows service I can't do this, it takes like this: "NT AUTHORITY\SYSTEM" Howcan I do this with windows service?? thanks..

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Dumb answer of the day. The service is running on a SERVER, the user name is what you started the service with. You nee dto get the username from the CLIENT and pass it to the service to record with the data.

          Never underestimate the power of human stupidity RAH

          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