Solved

Get username of page visitor with c# (aspx)

Posted on 2004-08-10
5
916 Views
Last Modified: 2008-03-17
Is there a possibility to get the username of a page visitor using C# (ASPX)?

We have an Active Directory server and we want to identify the users immediatly on our intranet page (so that they don't have to indicate the username when the have to make a login on restricted areas).
0
Comment
Question by:SiraX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
anilmane earned 200 total points
ID: 11760824
Try one of the following,

1> string user = User.Identity.Name
2> string user = System.Environment.UserName
3> string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name

Web.config Settings should be
<identity impersonate="true"/>
<authentication mode="Windows" />

.Hope this helps,

bye
0
 
LVL 2

Assisted Solution

by:waterhidden
waterhidden earned 50 total points
ID: 11760837
try:

Request.ServerVariables("REMOTE_USER")
0
 

Author Comment

by:SiraX
ID: 11762747
sorry but nothing of all that works ...

anilmane for 1> it returns nothing, 2 and 3 is almost the same but returns the user which is running the script on the IIS (IUSR_<Machinename>) and 3> returns nothing as well. (I also added the identity tag to web.config ... auth. mode was already set to "Windows".)

waterhidden, the server variable returns nothing as well :(


I know that in PHP the server variable REMOTE_USER worked but here it seems that it doesn't work. Could it be a configuration problem in IIS oder web.config?
0
 

Author Comment

by:SiraX
ID: 11763375
it works now ... I had to remove the anonymous access on the virtual directory/website.

thnx
0
 
LVL 2

Expert Comment

by:anilmane
ID: 11782812
It was my pleasure to help you out.Thats why we are here...

0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question