Getting domain \ username for intranet web application without logging in

I have a web application on our intranet (VS 2005). There are a couple of pages that do not require the user to register in the application (feedback and the default page). I am trying to get the domain and username to display and / or send feedback. Is there a way to do this without requiring a user to log in? I tried this.Request.ServerVariables["LOGON_USER"] and this.User.Identity.Name , but none of them worked.

Edit:
I should have mentioned that most users have Windows 2000 on their machines. It works on my development machine (XP), but not on the production network (where I have 2000).

+4
source share
2 answers

Teresa, I think this is what you are looking for ...

 AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal; WindowsIdentity identity = (WindowsIdentity)principal.Identity; String userName= principal.Identity.Name; 
+3
source

Assuming you have enabled Windows authentication in IIS for your site:

 public string user_Name { get { string x = Page.User.Identity.Name; x = x.Replace("YOURDOMAIN\\", ""); return x; } } 

x = x.Replace ("DOMAIN \", ""); deletes the user's DOMAIN section, for example, NISSAN \ rmcdonough

0
source

All Articles