Solved

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

Posted on 2008-06-25
4
8,849 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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