简体   繁体   English

使用C#进行Active Directory身份验证

[英]Active Directory Authentication With C#

I have a serious problem authenticating my user against AD. 我在针对AD验证用户身份时遇到严重问题。 I can use the PrincipalContext way or the DirectoryEntry way and check whether login was successful or not. 我可以使用PrincipalContext方式或DirectoryEntry方式,并检查登录是否成功。 But this is not enough for my case. 但这对我来说还不够。 I need to know why authentication failed(eg: password expiration, account locked, bad password count limit). 我需要知道为什么身份验证失败(例如:密码到期,帐户被锁定,错误的密码计数限制)。 Is there anyway of achieving this without using native win32 dll's. 反正有没有使用本机Win32 dll的实现。 By the way this may not be a web project all the time. 顺便说一下,这可能并非一直都是Web项目。 My optimal solution could be a generic one. 我的最佳解决方案可能是通用的解决方案。 Thanks for any help... 谢谢你的帮助...

You should get the reason for the error in the exception. 您应该获得异常中错误的原因。

Regardles of that you get the information if authentication will fail by using the PrincipalContext members like: 可以通过以下类似的PrincipalContext成员来获取有关身份验证是否失败的信息:

  • AccountExpirationDate (is the account expired) AccountExpirationDate(帐户已过期)
  • AccountLockoutTime (is the account locked) AccountLockoutTime(帐户已锁定)
  • Enabled (is the account enabled) 已启用(帐户已启用)
  • IsAccountLockedOut (is the account locked) IsAccountLockedOut(帐户已锁定)
  • PermittedLogonTimes (is the user allowed to login now) PermittedLogonTimes(是否允许用户立即登录)
  • PermittedWorkstations (is the user allowed to login from this client) 允许的工作站(允许用户从此客户端登录)

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

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