ayk
ayk

Reputation: 1497

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...

Upvotes: 2

Views: 674

Answers (1)

Daro
Daro

Reputation: 2020

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)

Upvotes: 1

Related Questions