简体   繁体   中英

Active Directory Authentication With C#

I have a serious problem authenticating my user against AD. I can use the PrincipalContext way or the DirectoryEntry way and check whether login was successful or not. 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. By the way this may not be a web project all the time. 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:

  • AccountExpirationDate (is the account expired)
  • AccountLockoutTime (is the account locked)
  • Enabled (is the account enabled)
  • IsAccountLockedOut (is the account locked)
  • PermittedLogonTimes (is the user allowed to login now)
  • PermittedWorkstations (is the user allowed to login from this client)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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