AD authentication error handling

Discussion in 'ASP General' started by Dan King, Oct 4, 2004.

  1. Dan King

    Dan King Guest

    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
    --
    __o
    _-\<,
    (_)/(_)____
    Dan King, Oct 4, 2004
    #1
    1. Advertising

  2. Dan King

    Dan King Guest

    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
    Dan King, Oct 4, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    4
    Views:
    323
    Steven Cheng[MSFT]
    Mar 3, 2005
  2. marcelino
    Replies:
    0
    Views:
    431
    marcelino
    Jan 28, 2004
  3. Mark Tarver
    Replies:
    22
    Views:
    1,275
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,913
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    174
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page