如何判断为什么集成 Windows 身份验证在 ASP.NET 中失败
在我们的 ASP.NET Intranet 应用程序中,我们使用 Windows 身份验证来对用户进行身份验证。
我们最近收到一个请求,要求向用户提供无法登录的原因。例如,告诉用户他们无法登录,因为他们的密码已过期,而他们无法登录,因为他们的帐户被锁定。
当帐户被锁定或密码过期时,用户无法登录应用程序。尝试登录 3 次后,IIS 将拒绝访问并将用户重定向到拒绝访问 (401) 页面。由于当 IIS 身份验证失败时,用户名不会传递到 Web 应用程序,因此我们无法检查帐户是否被锁定或密码是否已过期。
关于如何获取此信息有什么建议吗? 我们是否必须转向 AD 提供商的表单身份验证?
In our asp.net intranet application we are using windows authentication to authenticate the users.
We have recently had a request to give the user a reason for why they cannot login. For example, tell the user they can't login because their password has expired vs they can't login because their account is locked out.
When an account is locked out or the password has expired, the user cannot log on to the application. IIS will deny the access and redirect the user to the Access Denied (401) page after 3 login attempts. As the username is not passed to web application when IIS authentication fails, we won’t be able to check if the account is locked out or the password has expired.
Any suggestions on how to get this information?
Are we going to have to move to Forms authentication with an AD provider?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决此问题的简单方法是转向表单身份验证。但我知道您不想听到这个,并且这是不允许的或可行的解决方案,您的下一个选择是:
查看System.DirectoryServices
下面我是只需粘贴一些您可以使用的快速代码。请注意如何确定用户是否被锁定。这是 vb.net,但可以轻松更改为 C#。
The simple solution to this is to move to forms authentication. But being that I know you did not want to hear that and it is not allowed or a viable solution your next option is to:
Look into System.DirectoryServices
Below I'm just pasting some quick code you can play with. Notice how to determine if a user is locked out or not. This is vb.net but can be easily changed to C#.