简体   繁体   English

如何在ASP.NET MVC 5应用程序中对IIS .NET用户进行身份验证

[英]How to authentificate a IIS .NET User in an ASP.NET MVC 5 Application

I need to rewrite a Sliverlight Application into a ASP.NET MVC 5 application. 我需要将Sliverlight应用程序重写为ASP.NET MVC 5应用程序。 The User Accounts are stored as a ".NET User" in the IIS: 用户帐户在IIS中存储为“ .NET用户”:

IIS

I think this Database is related to it: 我认为该数据库与此有关:

D B

I assume, that there is some technologie build in in ASP.NET, that is for managing this users. 我假设ASP.NET中内置了一些技术,用于管理该用户。 Something like NetUser.Authentificate(username, password) 类似于NetUser.Authentificate(username, password)

How ever, I can not find some reference. 但是,我找不到一些参考。 I am sure, I am searching with the wrong keywords. 我敢肯定,我在搜索错误的关键字。

Can you point me on the right direction? 你能指出我正确的方向吗?

Based on the database tables, your old application used Membership Provider. 根据数据库表,您的旧应用程序使用了Membership Provider。

Membership Provider was shipped with ASP.Net 2.0, and more than a decade old already. 成员资格提供程序随ASP.Net 2.0一起提供,并且已经有十多年的历史了。

You have two solutions - 您有两种解决方案-

  1. Migrate old data to new ASP.Net Identity 2 tables. 将旧数据迁移到新的ASP.Net Identity 2表。 It is a prefer solution, but you need to understand how those tables work. 这是首选的解决方案,但是您需要了解这些表的工作方式。 Here is the example. 是例子。 Note : the article is for ASP.Net Identity 1 (but you get the idea). 注意 :本文适用于ASP.Net Identity 1(但您可以理解)。

  2. The second method is a quick and dirty way. 第二种方法是一种快速而肮脏的方法。 You call ASP.Net Membership Provider's methods manually to Authenticate and Authorize user inside ASP.Net MVC 5. You can read those methods here . 您可以手动调用ASP.Net成员资格提供程序的方法来对ASP.Net MVC 5中的用户进行身份验证和授权。您可以在此处阅读这些方法。

For example, 例如,

if(Model.IsValid)
{
   if(Membership.ValidateUser(model.Username, model.Password))
   { 
      // User is valid
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM