His error comes from the strSQL building he's doing (mostly :)

Here's a modified version that works in my environment based on the code you
presented.  The wscript.echo command is just to put the data on the screen.
I also didn't spend any time with the attributes she was looking for such as
telephone etc.  You'll need to put that back in there into the search and
continue from there.




strSearchString = "Firstname Lastname"
 
Dim objConn, strSQL, objRS, strConn

Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"


'Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = CreateObject("ADODB.Recordset")
'objConn.Provider = "ADsDSOObject"
strConn = "Active Directory Provider"
objConn.Open strConn
'strSQL = "SELECT givenname, sn, telephonenumber, otherphone " ', mobile,
facsimilyTelephoneNumber, pager 
strSQL = "SELECT AdsPath, cn FROM 'LDAP://DC=domain,DC=com' WHERE
objectCategory='person' AND objectClass='user' AND sn = '*'"
'strSQL = strSQL & "FROM 'LDAP://dc=domain, dc=COM' "
'strSQL = strSQL & "WHERE objectClass = 'user' "
'strSQL = strSQL & "AND (givenName = '*" & strSearchString & "*' OR sn = '*"
& strSearchString & "*' OR displayName = '*" & strSearchString & "*') "
'strSQL = strSQL & "ORDER BY sn"
wscript.echo strSQL
objRS.Open strSQL, objConn , 1, 1
'recordset.Open Source, ActiveConnection, CursorType, LockType, Options

While NOT objRS.EOF AND NOT objRS.BOF
 wscript.echo "in the while not loop"
 
 'strFirstName = objRS("givenname").value  
 'strLastName = objRS("sn").value  
 wscript.echo objRS("ADsPath").value
 wscript.echo objRS("cn").value
 
 
 wscript.echo("<b>" & strFirstName & " " & strLastName & "</b><br>")  
 wscript.echo("<br>")
 objRS.MoveNext
Wend
 
objRS.close
objConn.close 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jason Benway
Sent: Thursday, June 10, 2004 1:59 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [ActiveDir] AD Phone list

Here is his current code and error:

_______________________________________________________

The error 0x80004005 Unspecified Error occurs when I try to query for
various items. I've added "otherphone" to this code as an example. The error
occurs on line 18: "objRS.Open strSQL, objConn, 1, 1".
 
----------------------------------------------------------------------------
----
 
strSearchString = "Firstname Lastname"
 
Dim objConn, strSQL, objRS, strConn
Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.Recordset")
objConn.Provider = "ADsDSOObject"
strConn = "Active Directory Provider"
objConn.Open strConn
strSQL = "SELECT givenname, sn, telephonenumber, otherphone "
', mobile, facsimilyTelephoneNumber, pager strSQL = strSQL & "FROM
'LDAP://DOMAIN.COM' "
strSQL = strSQL & "WHERE objectClass = 'user' "
strSQL = strSQL & "AND (givenName = '*" & strSearchString & "*' OR sn = '*"
& strSearchString & "*' OR displayName = '*" & strSearchString & "*') "
strSQL = strSQL & "ORDER BY sn"
objRS.Open strSQL, objConn, 1, 1
 
While NOT objRS.EOF AND NOT objRS.BOF
 
 strFirstName = objRS("givenname").value  strLastName = objRS("sn").value
If objRS("telephonenumber").value = "" OR
IsNull(objRS("telephonenumber").value) Then
  strFullTelephoneNumber = ""
 Else
  strFullTelephoneNumber = objRS("telephonenumber").value  End If  If
join(objRS("otherphone").value) = "" OR
IsNull(join(objRS("otherphone").value)) Then
  strExtension = ""
 Else
  strExtension = join(objRS("otherphone").value)  End If
 
 Response.Write("<b>" & strFirstName & " " & strLastName & "</b><br>")
Response.Write("Phone Number: <b>" & strFullTelephoneNumber & "</b><br>")
 Response.Write("<br>")
 objRS.MoveNext
Wend
 
objRS.close
objConn.close
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/mail_list.htm
List FAQ    : http://www.activedir.org/list_faq.htm
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to