Link to home
Start Free TrialLog in
Avatar of Abdu_Allah
Abdu_Allah

asked on

Why this code return no errors even if I entered incorrect username?

I am authenticate users on Active Directory but error number (Err.Number ) is *always* zero even if I entered incorrect username!

Here is the code that I run on XP machine:

<%Const ADS_SECURE_AUTHENTICATION = 0

Function IsAuthenticated(Domain, Username, Password)
   On Error Resume Next
   Dim authNamespace, authObject
   Set authNamespace = GetObject("WinNT:")
       
   Set authObject = authNamespace.OpenDSObject("WinNT://" & Domain, Domain & "\" & strUsername, strPassword, ADS_SECURE_AUTHENTICATION)
       
   If Err.Number <> 0 Then
        IsAuthenticated = False
   Else
        IsAuthenticated = True
   End If
   Set authNamespace = Nothing
   Set authObject = Nothing
End Function

%>


Please help!
ASKER CERTIFIED SOLUTION
Avatar of amit_g
amit_g
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Abdu_Allah
Abdu_Allah

ASKER