tags:

views:

156

answers:

2

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

TIA, Theresa

+3  A: 

Theresa, I think this is what you're looking for...

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
WindowsIdentity identity = (WindowsIdentity)principal.Identity;

String userName= principal.Identity.Name;
matt_dev
A: 

I should have mentioned most of the users have Windows 2000 on their machines. Matt, should your code work on 2000? It works on my development machine (XP), but not on the production network (where I have 2000).

Theresa

Theresa