Advertisement

05.08.2008 at 12:32PM PDT, ID: 23387364
[x]
Attachment Details

LDAP authentication error codes (password expired) using current account credentials

Asked by KirkAHS in Active Directory, Visual Basic Programming, C# Programming Language

Tags: ,

Using System.Protocols.LdapConnection, I am trying to validate an Active Directory username and password to allow access to an application.

Everything works, however it throws the same error message (error code 49) whether the username & password are incorrect, or if the account is expired, or it is disabled.  

How can I determine, via this method or another, WHY the credentials are incorrect?  If a users password has expired, I want to handle that differently than if they just type in a wrong password.

NOTE: I am not looking to simply search and recurse through AD/LDAP to locate and return a specific user's account/password attributes -- I have the code to do that. This has to be specific to the user who is currently attempting to authenticate at runtime. And it must be done using the LDAP namespace (not ADSI or WinNT.)

Thanks so much!Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Try
    Dim con As New LdapConnection("server")
    Dim value As New System.Net.NetworkCredential(username, pwd, domain)
 
     con.AuthType = AuthType.Basic
     con.Credential = value
     con.Bind()
 
   Catch ex As Protocols.LdapException
        MessageBox.Show(ex.Message)
        MessageBox.Show(ex.ErrorCode)
[+][-]05.08.2008 at 09:31PM PDT, ID: 21530401

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Directory, Visual Basic Programming, C# Programming Language
Tags: VB.Net or C#, N/A
Sign Up Now!
Solution Provided By: BillyDvD
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628