How to get current logged in Windows username?

Discussion in 'ASP .Net' started by John Dalberg, Apr 6, 2005.

  1. John Dalberg

    John Dalberg Guest

    I want to automate the process of logging into an intranet. I want to pull
    out the username of the Windows user logged into the machine running the
    browser and use the username in my app. How can I get the logged in
    username?

    Do I have to disable the anonymous access in IIS? I rather not because the
    site is running under a certain domain user which has access to certain
    folder and network shares and the site needs thsi access for reading and
    writing files.

    --
    John Dalberg
     
    John Dalberg, Apr 6, 2005
    #1
    1. Advertising

  2. John Dalberg

    Eltoon Wang Guest

    Hi John,

    If you use Windows authentication and deny anonymous
    access, you can use HttpContext.Current.User.Identity.Name
    to get domain log on user name.

    HTH

    Elton Wang



    >-----Original Message-----
    >
    >
    >I want to automate the process of logging into an

    intranet. I want to pull
    >out the username of the Windows user logged into the

    machine running the
    >browser and use the username in my app. How can I get the

    logged in
    >username?
    >
    >Do I have to disable the anonymous access in IIS? I

    rather not because the
    >site is running under a certain domain user which has

    access to certain
    >folder and network shares and the site needs thsi access

    for reading and
    >writing files.
    >
    >--
    >John Dalberg
    >.
    >
     
    Eltoon Wang, Apr 7, 2005
    #2
    1. Advertising

  3. John Dalberg

    John Dalberg Guest

    On Wed, 6 Apr 2005 16:14:41 -0700, Eltoon Wang wrote:

    > Hi John,
    >
    > If you use Windows authentication and deny anonymous
    > access, you can use HttpContext.Current.User.Identity.Name
    > to get domain log on user name.



    I will explain what I need to do and someone may tell me the proper set up
    for this.

    I have an ASP.NET intranet that maintains its own user database where users
    log in through a form. I would like to streamline the login process so that
    users do not have to log in manually to the Intranet. If they are logged in
    to the domain and click on the Intranet's url, they are logged in the
    Intranet automatically. The Intranet app knows who they are and
    authenticate them behind the scene. My idea is that the Window's username
    is synced with the Intranet username. Somehow I want my asp.net to pull out
    the username from Windows and if it exists in the Intranet database, log in
    the user. The Intranet website runs under a domain user which has rights to
    certain documents folders for reading and writing purposes. That user is
    the anonymous user under which the site runs. If I disable anonymous
    security, then the Intranet website will run under which user? The logged
    in user? The site needs to run under a single user no matter who's logged
    in so that the web app has rights to certain folders locally.
    Do I enable impersonation? What's the proper set up for this? LDAP?

    TIA

    John Dalberg


    >
    >>-----Original Message-----
    >>
    >>
    >>I want to automate the process of logging into an

    > intranet. I want to pull
    >>out the username of the Windows user logged into the

    > machine running the
    >>browser and use the username in my app. How can I get the

    > logged in
    >>username?
    >>
    >>Do I have to disable the anonymous access in IIS? I

    > rather not because the
    >>site is running under a certain domain user which has

    > access to certain
    >>folder and network shares and the site needs thsi access

    > for reading and
    >>writing files.
    >>
    >>--
    >>John Dalberg
    >>.
    >>
     
    John Dalberg, Apr 7, 2005
    #3
  4. John Dalberg

    John Dalberg Guest

    On Wed, 6 Apr 2005 16:14:41 -0700, Eltoon Wang wrote:

    > Hi John,
    >
    > If you use Windows authentication and deny anonymous
    > access, you can use HttpContext.Current.User.Identity.Name
    > to get domain log on user name.




    How can you do something similar with Form authentication?

    John Dalberg



    >>-----Original Message-----
    >>
    >>
    >>I want to automate the process of logging into an

    > intranet. I want to pull
    >>out the username of the Windows user logged into the

    > machine running the
    >>browser and use the username in my app. How can I get the

    > logged in
    >>username?
    >>
    >>Do I have to disable the anonymous access in IIS? I

    > rather not because the
    >>site is running under a certain domain user which has

    > access to certain
    >>folder and network shares and the site needs thsi access

    > for reading and
    >>writing files.
    >>
    >>--
    >>John Dalberg
    >>.
    >>



    --

    John Dalberg
     
    John Dalberg, Apr 17, 2005
    #4
  5. Patrick Olurotimi Ige, Apr 18, 2005
    #5
  6. John Dalberg

    John Dalberg Guest

    On Sun, 17 Apr 2005 21:46:07 -0700, Patrick Olurotimi Ige wrote:

    > Try going through this articles:-
    >
    > http://support.microsoft.com/default.aspx?scid=kb;EN-US;308157
    >
    > http://www.c-sharpcorner.com/Code/2004/April/FormsAuthenticationWithAD.a
    > sp



    Thanks. These articles explain how forms authentication work which I
    already know. The point I was making is how to know who is the current user
    who authenticated on the Intranet form and if their session is still
    active. I wanted to get this info from my app which appears inside the
    Intranet. I can't read the Intranet app's cookie because I have no access
    to it because my app is a separate app and not part of it.

    It seems using Windows authentication is a better way. It also means that
    users do not need to authenticate to the Intranet if they are already
    authenticated in Windows.

    --
    John Dalberg
     
    John Dalberg, Apr 18, 2005
    #6
  7. John Dalberg

    John Dalberg Guest

    On Wed, 6 Apr 2005 16:14:41 -0700, Eltoon Wang wrote:

    > Hi John,
    >
    > If you use Windows authentication and deny anonymous
    > access, you can use HttpContext.Current.User.Identity.Name
    > to get domain log on user name.



    Now I am in a delimma. For HttpContext.Current.User.Identity.Name to work,
    "anonymous access" needs to be turned off but I need the Intranet app run
    under a domain user who has access to network shares. Otherwise if I have
    intergrated Windows security used then I have to maintain all kinds of ntfs
    permissions and probably all kinds of others issues which I can't think of
    right now. Access to folders is maintained by the Intranet app.

    John Dalberg





    >>-----Original Message-----
    >>
    >>
    >>I want to automate the process of logging into an

    > intranet. I want to pull
    >>out the username of the Windows user logged into the

    > machine running the
    >>browser and use the username in my app. How can I get the

    > logged in
    >>username?
    >>
    >>Do I have to disable the anonymous access in IIS? I

    > rather not because the
    >>site is running under a certain domain user which has

    > access to certain
    >>folder and network shares and the site needs thsi access

    > for reading and
    >>writing files.
    >>
    >>--
    >>John Dalberg
    >>.
    >>



    --
    John Dalberg
     
    John Dalberg, Apr 18, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    0
    Views:
    650
    keithb
    Feb 16, 2006
  2. Brendon Bezuidenhout

    Get Current logged in users

    Brendon Bezuidenhout, Nov 16, 2006, in forum: ASP .Net
    Replies:
    8
    Views:
    555
    Olaf Rabbachin
    Nov 17, 2006
  3. Replies:
    1
    Views:
    966
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 12, 2007
  4. mvr
    Replies:
    5
    Views:
    574
    Aaron Bertrand [SQL Server MVP]
    May 16, 2006
  5. Rodrigo Bermejo

    Windows - Get current logged user

    Rodrigo Bermejo, Sep 28, 2007, in forum: Ruby
    Replies:
    13
    Views:
    436
    Devi Web Development
    Oct 24, 2007
Loading...

Share This Page