[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2008-06-25
4
Medium Priority
?
8,861 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 260 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 240 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 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