简体   繁体   English

ASP.NET MVC 4,Windows身份验证和Active Directory

[英]ASP.NET MVC 4, Windows Authentication and Active Directory

I have two machines: 我有两台机器:

  1. Windows 2008 - for Active Directory Windows 2008-用于Active Directory
  2. Windows 7 - installed with IIS7, it also serves as development machine. Windows 7-与IIS7一起安装,它还可以用作开发机器。 Note that this PC is not member of the domain. 请注意,该PC不是该域的成员。

I tried Forms Authentication and it's working fine with this configuration in my web.config: 我尝试了表单身份验证,并且在我的web.config中使用此配置可​​以正常工作:

<connectionStrings>
    <add name="ADConn" connectionString="LDAP://192.168.0.21" />
</connectionStrings>

<membership defaultProvider="ADMembership">
  <providers>
    <add name="ADMembership"
         type="System.Web.Security.ActiveDirectoryMembershipProvider"
         connectionStringName="ADConn"
         connectionUsername="dominic"
         attributeMapUsername="sAMAccountName"
         connectionPassword="p@ssw0rd" />
  </providers>
</membership>

Now I want to change from Form to Windows Authentication. 现在,我想从窗体更改为Windows身份验证。 My questions are: 我的问题是:

  1. What configurations do I need to add in Web.Config to enable Windows Authentication? 我需要在Web.Config中添加哪些配置才能启用Windows身份验证?
  2. What configurations should be done in IIS to enable Windows Authentication? 在IIS中应进行哪些配置才能启用Windows身份验证?
  3. Do I need to configure Windows Firewall? 我需要配置Windows防火墙吗?
  4. When logging in using Windows Authentication, what should be my username? 使用Windows身份验证登录时,我的用户名应该是什么? Is it "192.168.0.21\\dominic" or "dominic"? 是“ 192.168.0.21 \\ dominic”还是“ dominic”?
  5. Did I miss to ask any question? 我想念任何问题吗?

I tried many tutorials today but it's either giving me 403 or it's not accepting my username and password. 我今天尝试了许多教程,但是要么给我403,要么不接受我的用户名和密码。 If you know any complete step-by-step tutorial, please let me know. 如果您知道任何完整的分步教程,请告诉我。

After days of research, it turns out that IIS at least, should be a member of the domain. 经过几天的研究,事实证明,至少IIS应该是该域的成员。 The client does not necessarily be a member of the domain. 客户端不一定是域的成员。

In the Web.Config, all I need to add is: 在Web.Config中,我需要添加的只是:

<authentication mode="Windows" />
<authorization>
  <allow users="*"/>
  <deny users="?" />
</authorization>

Connection string and membership are not necessary. 连接字符串和成员身份不是必需的。

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

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