error connecting to Active Directory via LDAP from ASP/VBScript pg



I'm rather new to the world of VBScript/ASP. I'm a *nix-head and have
been programming in PHP for years. I'm rather frustrated because I do
not know how to go about trouble-shooting an error I'm receiving in a
script I'm trying to implement to authenticate a user against AD.

The script is as follows (found it in these usenet groups):

<%@ Language=VBScript %>
<%
Dim username, password, ldapserver, ldap_path

' Construct the FQDN
ldap_path = "LDAP://cn=##,DC=ourcollege,DC=edu";

' Get the ldap server name into local variable by replacing the special
' charcter with the username
ldapserver = Replace(ldap_path,"##",Request.Form("username"))

Response.Write("<b>username:</b> " & Request.Form("username") & "<br
/>")
Response.Write("<b>ldapserver:</b> " & ldapserver & "<br />")

' Parse the username from the ldap path
username = Mid(ldapserver, InStr(8, ldapserver, "/") + 1)
Response.Write("<b>username:</b> " & username & "<br />")

' Get the password
Password = Request.Form("Password")

' Connect to the LDAP Directory
Set dso = GetObject("LDAP:")

' Validate the User Name and Password
Set objUser = dso.OpenDSObject(ldapserver, username, password, 0)

'Response.Write("<b>lobjuser.class:</b> " & lobjUser.class & "<br />")
'Response.Write("<b>err.description:</b> " & err.description & "<br
/>")

' Exit with error - Incorrect username & password - return to login.asp
page

'If Err.number<>0 Then
' Response.Write "<b>Result:</b> Authentication Failure.<br />"
' Set lobjUser = nothing
' Set dso = nothing
'Else
' Response.Write "<b>Result:</b> Success.<br />"
'End If

'To get information from the LDAP directory you need to know the
"attributes"
'available and then you can reference them. Ex:
'strUserName = lobjUser.Get("cn")>
%>

The above code generates the very unhelpful error:

error '8007054b'
/ldap_auth_02.asp, line 29

Is there a system log which will give me more information on the error
which occured? Is there something I can response.write to my browser
which might give me a more useful error message?

I recently put together a PHP script to connect to AD via LDAP. I had
to bind to AD using a username (RDN?) and password before I could
perform a query. (I apologize if I'm not using the appropriate
terminology.) I then passed AD our Base DN, filter, and search terms.

I can't find any documentation on this. My ultimate goal is to
authenticate a user with their AD credentials.

.



Relevant Pages

  • Re: login at a site.
    ... then the script redirects to ... $warning is a string to be ... Then test if the username and password entered match with the ones on ...
    (alt.php)
  • $_ENV not working for me with PHP 4.2.0
    ... I've been trying to make a simple script which just ... outputs the username that the script is currently ... running PHP 4.2.0 and it correctly outputs the ... Do you Yahoo!? ...
    (php.general)
  • Re: form processing question
    ... see whether that username has already been taken up by someone else (a ... How can I send the text entered in the text box to a server side PHP ... ONCHANGE event to the AJAX form submission. ... That makes it execute the same script that generated the form, ...
    (comp.lang.php)
  • Re: PHP LDAP Question
    ... Directory Server, using PHP of course, but I'm having some problems... ... I get a LDAP Error Code 10 when the Script tries to add the ...
    (php.general)
  • Using variables in login script:
    ... script, which allows user's to enter there username, password in text ...
    (comp.lang.php)

Loading