LDAP mystery (intermittent)

From: Tony Lavender (moc.ocaidemorp_at_rednevalt.org)
Date: 04/27/04


Date: Tue, 27 Apr 2004 12:08:22 -0600

I have some ASP code that uses the LDAP provider to return a few Active
Directory field values for a given user. It works sometimes, but other times
it won't work unless I remove one of the fields from the query (and, when
this happens, the other values are returned as single-member arrays).

Here's the code. Sometimes I have to remove "department" to make it work, or
it fails on "RS.Open strRS, Conn, 1, 1" with:

Provider error '80004005'
Unspecified error

(which seems to indicate the "department" field doesn't exist, but I know it
does)
Ideas, anyone?

--------------------------------------------------
 Dim Conn, strRS, RS, strConn
 Set Conn = Server.CreateObject("ADODB.Connection")
 Set RS = Server.CreateObject("ADODB.Recordset")
 Conn.Provider = "ADsDSOObject"
 strConn = "Active Directory Provider"
 Conn.Open strConn
 strRS = "SELECT department, telephoneNumber, cn FROM 'LDAP://xxxxxx' WHERE
sAMAccountName='" & UserName & "' AND objectClass='*'"
 RS.Open strRS, Conn, 1, 1

 returnval = RS("cn")
 if isarray(returnval) then
  ad_name = returnval(0)
 else
  ad_name = returnval
 end if
 returnval = RS("telephoneNumber")
 if isarray(returnval) then
  ad_Tel = returnval(0)
 else
  ad_Tel = returnval
 end if

 RS.Close
 Set RS = nothing
 Conn.Close
 set Conn = nothing



Relevant Pages

  • RE: Problem with ADO Code
    ... Set Conn = New ADODB.Connection ... Set rst = New ADODB.Recordset ... rst.Open "qryTotalSquareFeet", Conn, adOpenDynamic, adLockOptimistic ...
    (microsoft.public.access.formscoding)
  • Re: Automatic Report
    ... Public Sub CheckProbs() ... Dim rsProblems as ADODB.Recordset ... Dim conn as ADODB.Connection ... Set conn = Current Project.Connection ...
    (microsoft.public.access.reports)
  • Problem with ADO Code
    ... I am trying to update a query with pricing after a level of 100sq ft is ... Dim Conn As ADODB.Connection ... Set Conn = New ADODB.Connection ...
    (microsoft.public.access.formscoding)
  • Re: how to delete all field in the dbase file *.dbf except 2 field
    ... Public conn As ADODB.Connection ... Private Sub Command1_Click ... Dim dbf_name As String ... Set conn = New ADODB.Connection ...
    (microsoft.public.vb.database)