?
Solved

How to find current Windows User \

Posted on 2012-08-13
7
Medium Priority
?
505 Views
Last Modified: 2012-08-27
I have a web application in ASP.NET
I am using Forms Authentication with AD.
On the login screen I want to fill in the current windows user's name in the login form.
How do I do this ?
0
Comment
Question by:vu3lmg
  • 5
7 Comments
 
LVL 12

Expert Comment

by:Seaton007
ID: 38289878
Here is an example of how to get the current user name (it puts the user name in the "strUserName" variable):
Dim strUserName

Set objNetwork = CreateObject("WScript.Network")
strUserName = objNetwork.UserName

Open in new window

0
 
LVL 1

Author Comment

by:vu3lmg
ID: 38289902
Dear Seaton007
I am using C#, which "using ..." includes this "WScript.NetWork" class ?
-VU3LMG
0
 
LVL 20

Expert Comment

by:informaniac
ID: 38290929
Use

HttpContext.Current.User.Identity

Open in new window



http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:vu3lmg
ID: 38301987
Dear informaniac
HttpContext.Current.User.Identity 

Open in new window

is returning blank, what could be the reason ?
VU3LMG
0
 
LVL 1

Author Comment

by:vu3lmg
ID: 38302413
Just FYI I am using "Forms Authentication with AD user"
not "Windows Authentication"
When I use "Environment.UserName" it returns "NETWORK SERVICE".

VU3LMG
0
 
LVL 1

Accepted Solution

by:
vu3lmg earned 0 total points
ID: 38322470
I changed the properties of Login.aspx as shown in the image below and
HttpContext.Current.Request.ServerVariables["LOGON_USER"].ToString();

Open in new window

returns the current windows.
LoginPropertiesForIIS.bmp
0
 
LVL 1

Author Closing Comment

by:vu3lmg
ID: 38335846
Contaced an expert and got the advise as mentioned in the solution above.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month16 days, 10 hours left to enroll

864 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