Solved

Get username of page visitor with c# (aspx)

Posted on 2004-08-10
5
909 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select only the top record in a left join 13 49
Connection to multiple databases 13 41
Html split(text) Part2 6 38
Table doesn't show the lines! 3 33
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

736 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