ASP.NET MVC - 验证对Active Directory用户,但需要用户名和密码将被输入 [英] ASP.NET MVC - Authenticate users against Active Directory, but require username and password to be inputted

查看:204
本文介绍了ASP.NET MVC - 验证对Active Directory用户,但需要用户名和密码将被输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序MVC3将要求用户对AD进行身份验证。我知道有在MVC3创建一个内联网应用,可自动进行身份验证对AD用户的选项,但它使用Windows身份验证,并自动记录它们。此应用程序可在打开工作站,用户需要输入他们的域用户名和密码进行访问。任何示例或在线教程将是巨大的。一个例子项目是例外的。

I'm developing a MVC3 application that will require a user to be authenticated against an AD. I know that there is the option in MVC3 to create an Intranet Application that automatically authenticates a user against an AD, but it uses Windows Authentication and automatically logs them on. This application may be accessed on 'Open' workstations where the user will need to enter their Domain Username and Password. Any examples or online tutorial would be great. An example project would be exceptional.

推荐答案

您可以使用与窗体身份验证标准的Internet应用程序模板并插入 ActiveDirectoryMembershipProvider 的web.config

You can use the standard Internet application template with forms authentication and insert an ActiveDirectoryMembershipProvider into the web.config:

<connectionStrings>
    <add name="ADConnectionString" connectionString="YOUR_AD_CONN_STRING" />
</connectionStrings>

<system.web>
    <authentication mode="Forms">
        <forms name=".ADAuthCookie" loginUrl="~/Account/LogOn" timeout="15" slidingExpiration="false" protection="All" />
    </authentication>
    <membership defaultProvider="MY_ADMembershipProvider">
        <providers>
            <clear />
            <add name="MY_ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
        </providers>
    </membership>
</system.web>

在这种方式,您获得互联网应用程序模板登录表单,并验证对广告给你。

In this way you get the Internet application template login form, and it validates against AD for you.

然后,它只是一个部分的AccountController 清理事项移除重置密码/更改密码/注册功能,只留下登录。

Then it's just a matter of some AccountController cleanup to remove reset password/change password/register functionality leaving just Login.

这篇关于ASP.NET MVC - 验证对Active Directory用户,但需要用户名和密码将被输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆