?
Solved

Retrieving username

Posted on 2013-05-27
4
Medium Priority
?
214 Views
Last Modified: 2013-06-03
I have workstations with a variable that gives the logged on user id, how can I retrieve this value through a dot.net asp web application, that I am developing ?

The web server resides in a different domain from the users and there is also no trust between the domains, I have the anonymous IIS account setup for the web app, however using other methods, this is the value that is returned for the logged on user.

I would also be looking to take the user id and do a lookup on it in AD, so I can use the First name, second name values within AD.

I'm using VB.net with Visual Web Developer.

Any ideas ?
0
Comment
Question by:ndr-itsolutions
[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
4 Comments
 
LVL 9

Expert Comment

by:jsdray
ID: 39199122
TextBox6_AddDataControl1.Text = Request.ServerVariables("LOGON_USER")
0
 

Author Comment

by:ndr-itsolutions
ID: 39199135
Still get the same result, that is, the code returns the anonymous user account of the IIS server and not the username of the logged on user's workstation.
0
 
LVL 4

Accepted Solution

by:
EddyvanOpdorp earned 1500 total points
ID: 39199433
See here: http://forums.asp.net/t/1179997.aspx

Quote:
In ASP.NET, please use User.Identity.Name to get the logon user. User.Identity.Name might be empty if Anonymous Authentication is enabled in IIS.

http://msdn2.microsoft.com/en-us/library/system.web.httpcontext.user.aspx

Here is the logical to check if the identity is available.

VB.NET

' Gets the name if authenticated.
If User.Identity.IsAuthenticated Then
    Label1.Text = User.Identity.Name
Else
    Label1.Text = "No user identity available."
End If

C#

' Gets the name if authenticated.
if (User.Identity.IsAuthenticated)
    Label1.Text = User.Identity.Name;
else
    Label1.Text = "No user identity available.";

Environment.UserName is the running thread identity. If you have enabled Impersonation as Mark said, you can find out the returning result will be different. However this requires ASP.NET Impersionation. If you don't need ASP.NET Impersonation and dealing with the thread identity, you can ignore Environment.UserName if and just use User.Identity.Name.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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