Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect user logged on a computer using ASP.NET app

I want to develop an ASP.NET application that can detect the user logged on a Window Domain. These credentials are going to be used to logging on the ASP.NET application.

How can I do this?

Thanks!

like image 361
VansFannel Avatar asked Dec 06 '25 05:12

VansFannel


2 Answers

In IIS, turn on Integrated Windows Authentication, and in code, if you use:

Request.ServerVariables["LOGON_USER"]

it will return the windows username of the logged in user, i.e. MYDOMAIN\MYUSERNAME

like image 122
JonoW Avatar answered Dec 07 '25 17:12

JonoW


For ASP.net, you can probably use

HttpContext.Current.User.Identity

If IIS is configured correctly (no anonymous logons, at least)

like image 38
Lennaert Avatar answered Dec 07 '25 19:12

Lennaert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!