?
Solved

Get username of page visitor with c# (aspx)

Posted on 2004-08-10
5
Medium Priority
?
924 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 800 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

719 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