Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Domain User name - Output to screen

Status
Not open for further replies.

Scorez2000

Programmer
Feb 5, 2004
87
0
0
GB
Hi All,

On our intranet, I would like to have the user's name appear at the top right. We use a domain and the only people accessing the site should be people logged onto the domain.

Classic ASP or ASP.NET will do. I just need to know how to pull the user's name or username from Active Directory based on who they are logged on as.

Thanks in advance.
 
Check out ther Request.ServerVariables collection


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I tried the Request.ServerVariables("LOGON_USER") in both asp and an aspx file and neither output anything.
 
>>We use a domain and the only people accessing the site should be people logged onto the domain.


meaning u use windows authentication??? there are methods in windows authentication itself to find out the current user's id...

Known is handfull, Unknown is worldfull
 
there are methods in windows authentication itself to find out the current user's id"

Yes, and I'm asking how that's done.
 
Hi,

Make sure you are using windows authentication.

<authentication mode="Windows" />
<identity impersonate = "true" />

Then I use this function.

Public Function ExtractUserName(ByVal path As String) As String
Dim userPath() As String = path.Split(New Char() {"\\"})
Return userPath(userPath.Length - 1)
End Function

I then call this from my header

Dim userx As New JBXEL.DataManager
Dim ux As String = userx.ExtractUserName(HttpContext.Current.User.Identity.Name)
LblUserName.Text = ux

or more simply if you like, in the header code use:-

Dim str1 As String = HttpContext.Current.User.Identity.Name
Dim repStr As String = str1.Replace("YourServername\", "")
LblUserName.Text = repStr

HTH

J

----------------------------------------------------------------------------------------
A community development project in asp.net -
 
>>HttpContext.Current.User.Identity.Name

thats the one...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top