且构网

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

ASP.NET应用程序通过Windows身份验证或窗体身份验证验证到Active Directory或SQL

更新时间:2023-12-01 09:39:28

这是我处理的基础上的这个信息的:

This is the way I've handled a similar situation based on this info:

  1. 配置为使用窗体身份验证的应用程序。
  2. 将LoginUrl到名为WinLogin.aspx页面。
  3. 在WinLogin.aspx,使用Request.ServerVariables [LOGON_USER]来获取用户名,然后调用FormsAuthentication.RedirectFromLoginPage(authorizedUserName,false)来登录他们。我想你可以手动检查Active Directory作为这一点为好。
  4. 创建一个html页面重定向到一个名为的Login.aspx页
  5. 的Login.aspx是标准的用户名/密码登录。
  6. 在IIS中,启用集成身份验证和匿名在整个网站,但拒绝对WinLogin.aspx匿名访问。
  7. 在IIS中,设置401错误在步骤3中创建的页面。

什么基本情况是,当一个unauthenicated用户点击该网站,他们重定向到WinLogin.aspx。因为匿名是关闭的,集成的安全,使一张支票。如果通过,您的自定义code在WinLogin可以运行。如果综合安全检查失败,出现401错误。您的自定义401页面重定向到l​​ogin.aspx的,用户可以登录使用的用户名和密码与SQL提供。

What basically happens is that when an unauthenicated user hits the site, they're redirected to WinLogin.aspx. Since anonymous is turned off, integrated security makes a check. If that passes, your custom code in WinLogin can run. If the integrated security check fails, a 401 error occurs. Your custom 401 page redirects to Login.aspx where the user can log in using their username and password with the SQL provider.