ASP grabbing windows username

Discussion in 'ASP General' started by Ryan Ritten, Jun 7, 2004.

  1. Ryan Ritten

    Ryan Ritten Guest

    Anyone know how it is possible for windows to get the name of the user
    logged in?

    I know if you do :

    Request.Servervariables ("AUTH_USER")

    it displays the username of the person logged in, but is there a way
    to get the "Full name" of that user in the active directory?

    Ie, if they log in with the username jsmith, I from that I know there
    full name is John Smith.

    Any ideas?

    TIA

    Ryan R
     
    Ryan Ritten, Jun 7, 2004
    #1
    1. Advertising

  2. Yes, you use ADSI.
    http://groups.google.com/groups?q=asp adsi full name group:*asp*&ie=UTF-8&hl=en&btnG=Google Search

    However, the ASP page must execute in the context of a user who has the
    authority to query active directory.

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Ryan Ritten" <> wrote in message
    news:...
    > Anyone know how it is possible for windows to get the name of the user
    > logged in?
    >
    > I know if you do :
    >
    > Request.Servervariables ("AUTH_USER")
    >
    > it displays the username of the person logged in, but is there a way
    > to get the "Full name" of that user in the active directory?
    >
    > Ie, if they log in with the username jsmith, I from that I know there
    > full name is John Smith.
    >
    > Any ideas?
    >
    > TIA
    >
    > Ryan R
     
    Aaron [SQL Server MVP], Jun 7, 2004
    #2
    1. Advertising

  3. "Ryan Ritten" <> wrote in message
    news:...
    > Anyone know how it is possible for windows to get the name of the user
    > logged in?
    >
    > I know if you do :
    >
    > Request.Servervariables ("AUTH_USER")



    write a VB6 (or use some other language) and wrap the Secur32.dll exported
    API
    GetUserNameEx(NameDisplay, .. )

    and it will show you the current user (namedisplay is a win32 constant which
    equals 3)
    --
    compatible web farm Session replacement for Asp and Asp.Net
    http://www.nieropwebconsult.nl/asp_session_manager.htm
     
    Egbert Nierop \(MVP for IIS\), Jun 8, 2004
    #3
  4. enum Extended_Name_Format
    NameDisplay = 3,
    NameCanonical=7,
    NameFullyQualifiedDN=1
    etc...
    end enum

    Private Declare Function GetUserNameEx Lib "Secur32.DLL" Alias
    "GetUserNameExW" (ByVal fmt As EXTENDED_NAME_FORMAT, _
    ByVal lpNameBuffer As Long, ByRef nSize As Long) As Long

    Public Function GetUserName(byval fmt as Extened_name_Format) As String
    Dim sBuf As String
    Dim UsrLength As Long
    Dim lResult As Long
    UsrLength = 100
    sBuf = Space$(100)
    Dim lErr As Long
    lResult = GetUserNameEx(fmt , sBuf, UsrLength)
    If lResult = 0 Then
    lErr = GetLastError
    End If
    GetUserName = Left(sBuf, UsrLength)
    End Function

    --
     
    Egbert Nierop \(MVP for IIS\), Jun 8, 2004
    #4
    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. darrel
    Replies:
    2
    Views:
    709
    Bruce Barker
    Mar 24, 2005
  2. DMG
    Replies:
    4
    Views:
    1,049
  3. Shailesh Patel
    Replies:
    0
    Views:
    478
    Shailesh Patel
    Nov 8, 2006
  4. Adrian Forbes [ASP MVP]

    Need help grabbing info from asp dropdown list box

    Adrian Forbes [ASP MVP], Oct 22, 2003, in forum: ASP General
    Replies:
    2
    Views:
    107
    Melissa
    Oct 23, 2003
  5. Tom Petersen

    grabbing current username via ADSI?

    Tom Petersen, Jan 18, 2005, in forum: ASP General
    Replies:
    3
    Views:
    118
    Jeff Cochran
    Jan 18, 2005
Loading...

Share This Page