且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET MVC中的Active Directory身份验证

更新时间:2023-02-17 12:15:57

您需要从表单切换到Windows身份验证并拒绝匿名用户。



 <  配置 >  
< system.web an> >
< authentication mode = Windows / >
<
授权 >
< deny 用户 = / >
< / authorization >
< / system.web >
< / configuration >





这应该在用户访问系统时打开一个登录窗口。



有一个全面的列表有关模式和实践网站的示例:

如何:使用Windows身份验证在ASP.NET 2.0中 [ ^ 一>


I am new for Active Directory authentication. Need to create login using active directory. Please help me with explained example or link where i can learn to create active directory login



<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="ADService" attributemapusername="sAMAccountName" />
      </providers>
    </membership>



What I have tried:

http://www.code.colostate.edu/active-directory-authentication-in-aspnet-mvc-5.aspx

http://www.benramey.com/2014/10/20/active-directory-authentication-in-asp-net-mvc-5-with-forms-authentication-and-group-based-authorization/

You'll want to switch from forms to windows authentication and deny anonymous users.

<configuration>
  <system.web>
    <authentication mode="Windows"/>
    <authorization>
        <deny users="?"/>
    </authorization>
  </system.web>
</configuration>



This should open a login window when users access the system.

There's a comprehensive list with examples on the patterns and practices site at:
How To: Use Windows Authentication in ASP.NET 2.0[^]