Solved

How to get windows user ID in C# web application (asp.net 2.0)?

Posted on 2008-06-25
4
8,858 Views
Last Modified: 2013-11-07
How to get windows user ID in C# web application?
To clarify, I am talking about login ID that user uses to login to his working machine. (he/she has to press Ctrl-Alt-Del and enter login and password to start working)

I was looking around and  one of the suggestion was to use:  System.Environment.UserName;
But, this gives (by my opinion) account name under which the application is logged to the server that hosts application. In my case I get "ASPNET" and that is not my windows ID.

I assume that for this I will have to connect to Active Directory. How can I do that and how to query Active Directory. Thanks.
0
Comment
Question by:sacvb
[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
4 Comments
 
LVL 8

Accepted Solution

by:
Chumad earned 65 total points
ID: 21869751
You'll need to disable anonymous access on the website.

Once you've got Anony turned off, you can see who the authenticated user:  Page.User.Identity.Name
0
 
LVL 8

Expert Comment

by:Chumad
ID: 21869755
string authUser = Page.User.Identity.Name;
0
 
LVL 18

Assisted Solution

by:carlnorrbom
carlnorrbom earned 60 total points
ID: 21869936
Hi,

Or You could use:

Request.LogonUserIdentity.Name.ToString 'will give you the logged on windows/domain account in DOMAIN\username format as string
Request.LogonUserIdentity.User.ToString 'will give you the domain SID of the logged on user as a string

/Carl.
0
 

Author Comment

by:sacvb
ID: 21875551
Thanks all
0

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

690 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