AD authentication error handling

D

Dan King

I've created a login page to connect to Active Directory and retrieve a list
of groups.
If someone enters the wrong username/password, the web browser returns this
error:

Provider error '80040e09'

Permission denied.

/ct/useradd.asp, line 45

I would like to be able to retrieve this error and present a "You have
entered invalid information.." page.
If I enter an "On Error Resume Next" line the server CPU just jumps to 100%
utilization and the page never returns anything.
Anyone know how to handle this error so I can push out a login arror page?

Here is my code for the AD connection and request.

'''''''''''''''''''''''''''''''''''

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADSDSOObject"
objConnection.Open "ADs Provider", uName, uPass

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "<LDAP://" & dcIP & "/" & adOU &
">;(objectCategory=group)" & ";distinguishedName,name;subtree"

Set objRecordSet = objCommand.Execute '<=THIS IS THE LINE THE SERVER HANGS
ON WITH BAD USERNAME/PASSWORD

'''''''''''''''''''''''''''''''''''

Thanks,
Dan
 
D

Dan King

I figured it out.
I needed to put "On Error GoTo 0 in there, otherwise the system would try to
parse data it never got back, and would just lockup.
Functional code looks like this:
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADSDSOObject"
objConnection.Open "ADs Provider", uName, uPass

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "<LDAP://" & dcIP & "/" & adOU &
">;(objectCategory=group)" & ";distinguishedName,name;subtree"

On Error Resume Next
Set objRecordSet = objCommand.Execute
errorNum = err.number
On Error GoTo 0
If errorNum <> 0 Then
Response.Redirect "/ct/login.asp?error"
End If
Err.Clear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top