Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Authentication with ASP.NET MVC

I've built a custom login system for my asp.net mvc 1.0 web application as I store large amounts of user data for each user (I decided against trying to add custom tables for the windows authentication due to this). The login system basically uses SQL Server (2005 or 2008) and my own database and table structure which is pretty standard. A users table with an unique id, username and hashed password which is linked to my other tables of user related data.

My question is, how can I tie my system to use Windows Authentication logins. I would like to allow the administrator to for a user (as defined in my system) select a Windows Authentication login and perhaps add a value to something in my custom table that I can use to authenticate them?

The question is probably phrased wrong and I might have misunderstood how Windows Authentication works but I would like to offer the option in my web application.

like image 529
Phil Avatar asked Sep 10 '09 15:09

Phil


People also ask

How can add window authentication in ASP.NET MVC?

By default MVC apps use Form Authentication and Simple Membership, so you need to make it "false" to run Windows Authentication. Select the project name in Solution Explorer and then in the Property Explorer, click to enable Windows Authentication.

How does ASP.NET Windows Authentication work?

Windows Authentication relies on the operating system to authenticate users of ASP.NET Core apps. Windows Authentication is used for servers that run on a corporate network using Active Directory domain identities or Windows accounts to identify users.

How do we implement Windows Authentication?

On the taskbar, click Start, and then click Control Panel. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off. Expand Internet Information Services, then World Wide Web Services, then Security. Select Windows Authentication, and then click OK.

How authentication and Authorization works in ASP.NET MVC?

Windows Authentication is used in conjunction with IIS authentication. The Authentication is performed by IIS in one of three ways such as basic, digest, or Integrated Windows Authentication. When IIS authentication is completed, then ASP.NET uses the authenticated identity to authorize access.


1 Answers

If you have Windows Auth enabled on your site then you should be able to use User.Identity.Name to get their NT/Active Directory user name of the currently logged in user, and match that to a column in your users table.

like image 156
Scrappydog Avatar answered Nov 05 '22 23:11

Scrappydog