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. Web Development
  3. ASP.NET
  4. Get Username for logged in user

Get Username for logged in user

Scheduled Pinned Locked Moved ASP.NET
questionsysadminwindows-admindebugginghelp
3 Posts 3 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.
  • D Offline
    D Offline
    dataminers
    wrote on last edited by
    #1

    I am having trouble getting a logged in username to use on an intranet site. I use HttpContext.Current.Request.ServerVariables["LOGON_USER"] I Get "Network Service". If I run the application in debug locally I get the Domain\username but not when I run it on our intranet. I think its related about web.config and IIS 7 settings. How can I fix it? Thanks...

    M 1 Reply Last reply
    0
    • D dataminers

      I am having trouble getting a logged in username to use on an intranet site. I use HttpContext.Current.Request.ServerVariables["LOGON_USER"] I Get "Network Service". If I run the application in debug locally I get the Domain\username but not when I run it on our intranet. I think its related about web.config and IIS 7 settings. How can I fix it? Thanks...

      M Offline
      M Offline
      mcmathys04
      wrote on last edited by
      #2

      Try using HttpContext.Current.User.Identity.Name

      G 1 Reply Last reply
      0
      • M mcmathys04

        Try using HttpContext.Current.User.Identity.Name

        G Offline
        G Offline
        GenJerDan
        wrote on last edited by
        #3

        or System.Web.HttpContext.Current.Request.LogonUserIdentity.Name; if you want the SAMAccountName or

        public string Whoami()
        {
        string str;
        int idx;
        str = System.Web.HttpContext.Current.Request.LogonUserIdentity.Name;
        idx = str.IndexOf("\\");
        return str.Substring(idx + 1);
        }

        if you don't want the Domain in there.

        ..and water fell from the sky like rain.

        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