Link to home
Start Free TrialLog in
Avatar of vu3lmg
vu3lmgFlag for United States of America

asked on

How to find current Windows User \

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 ?
Avatar of Seaton007
Seaton007
Flag of United States of America image

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

Avatar of vu3lmg

ASKER

Dear Seaton007
I am using C#, which "using ..." includes this "WScript.NetWork" class ?
-VU3LMG
Avatar of vu3lmg

ASKER

Dear informaniac
HttpContext.Current.User.Identity 

Open in new window

is returning blank, what could be the reason ?
VU3LMG
Avatar of vu3lmg

ASKER

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

VU3LMG
ASKER CERTIFIED SOLUTION
Avatar of vu3lmg
vu3lmg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vu3lmg

ASKER

Contaced an expert and got the advise as mentioned in the solution above.