ASP grabbing windows username

R

Ryan Ritten

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
 
E

Egbert Nierop \(MVP for IIS\)

Ryan Ritten said:
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)
 
E

Egbert Nierop \(MVP for IIS\)

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

--
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top