Click here to Skip to main content
15,917,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Team,

I want current window User ID.
I have below :
IIS : IIS7
Application Pool :
ASP.NET v4.0


I have tried following codes -

C#
Win_Login_ID = Environment.UserName;
        Win_Login_ID = HttpContext.Current.User.Identity.Name.ToString();
        Win_Login_ID = WindowsIdentity.GetCurrent().Name.ToString();
        System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
        Win_Login_ID = p.Identity.Name.ToString();
        Win_Login_ID = Request.ServerVariables[5].ToString();
        Win_Login_ID = Page.User.Identity.Name.ToString();


This is running on local PC but - user Name is not getting when I run it on Intranet / from IIS - Browse *.80(Http) link fron IIS

Please help...!!!

Edit: Additional question from OP-comment
What setting I need to do in my IIS???
Posted
Updated 12-Apr-12 23:41pm
v2
Comments
Pravinkarne.31 13-Apr-12 3:00am    
What setting I need to do in my IIS???
Nelek 13-Apr-12 5:42am    
Don't forget you can use the "improve question" link (green on the right side below your message) to edit your message and add whatever you need. :)

Make sure Windows Authentication is turned on and disable anonymous authentication.
 
Share this answer
 
Comments
Pravinkarne.31 21-Apr-12 6:55am    
Thank You!!!
I tried

{
Win_Login_ID = HttpContext.Current.User.Identity.Name.ToString();

turn on Windows Authentication, and;

disable anonymous authentication.;
}

in IIS7 + windows server 2008R2 and works fine now :)

Thanks heaps!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900