DQELER
DQELER

Reputation: 133

Get windows authenticated user name in .net app?

How to get windows authenticated user name in .net application? My app is hosted on IIS. There is no Login form. But, I want to get the windows user name of the persons browsing it. I tried all the request objects. principal object getcurrent().name returns IIS app pool user name. But not the actual user. Please help. Thanks.

Upvotes: 3

Views: 3040

Answers (2)

Daniel A. White
Daniel A. White

Reputation: 191037

You can't unless you enable windows authenication.

Upvotes: 1

Adam Tuliper
Adam Tuliper

Reputation: 30152

You cannot. Unless your application is using windows auth (and they could be prompted at some point like in firefox) you cannot get this information. If you do allow it, then access it via http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx

HttpContext.User.Identity.Name

again though - they could be prompted for a login at some point.

Upvotes: 4

Related Questions