• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 674
  • Last Modified:

ASP LDAP Query

Hey all ... can't seem to pull a few attributes from AD ... this query works :  
---------------------------------------------------------------------------------------------
<LDAP://domain.com>;(&(objectCategory=person)(objectClass=user)(sAMAccountName=JSmith));sn,givenName,sAMAccountName,department,ADsPath;subtree
---------------------------------------------------------------------------------------------

... but as soon as I change the attributes and add any one of these: "description", "office", or "phone", it errors out :
---------------------------------------------------------------------------------------------
<LDAP://domain.com>;(&(objectCategory=person)(objectClass=user)(sAMAccountName=JSmith));sn,givenName,sAMAccountName,department,ADsPath,description,office,phone;subtree
---------------------------------------------------------------------------------------------

When those attributes are added, it dies at this line :
    Set objRecordSet = objCommand.Execute

What gives ? How do I pull a users description, office, or phone from LDAP ?  
Any good web links to pulling user info from AD using LDAP & ASP ?
0
Gitcho
Asked:
Gitcho
  • 3
  • 2
1 Solution
 
jmelikaCommented:
What error does it give you?

JM
0
 
GitchoAuthor Commented:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch
LDAP.asp, line 134

---------------------------------------------------------------------------------------

strAttributes = "sn,description,givenName,sAMAccountName,department,ADsPath"
arrAttributes = split(strAttributes,",")
      
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
objCommand.Properties("Sort On") = "displayName"    
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
      'return empty if result set empty
      XMLUserData = "<?xml version='1.0' encoding='ISO-8859-1'?><root></root>"
      Exit Function
End If
XMLtext = "<?xml version='1.0' encoding='ISO-8859-1'?>" & vbNewLine
XMLtext = XMLtext & "<xml>" & vbNewLine
' Loop through results
Do Until objRecordSet.EOF
      XMLtext = XMLtext & "<user>" & vbNewLine
      For i=0 to Ubound(arrAttributes)
            XMLtext = XMLtext & "<" & arrAttributes(i) & ">" & objRecordSet.Fields(arrAttributes(i)) & "</" & arrAttributes(i) & ">" & vbNewline
      Next
      XMLtext = XMLtext & "</user>" & vbNewLine
      objRecordSet.MoveNext
Loop
XMLtext = XMLtext & "</xml>"
0
 
jmelikaCommented:
OK another question.  Which line is 134?

JM
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GitchoAuthor Commented:
oh ... sorry ...

XMLtext = XMLtext & "<" & arrAttributes(i) & ">" & objRecordSet.Fields(arrAttributes(i)) & "</" & arrAttributes(i) & ">" & vbNewline

It seems that the query executes just fine (there's no error at the "Set objRecordSet = objCommand.Execute" line), but I can't refer to the property in the variable.
0
 
GitchoAuthor Commented:
i figured it out ... "description", "office", and "phone" are multi-valued items (arrays), and can't be referred to directly.
0
 
moduloCommented:
Closed, 500 points refunded.

modulo
Community Support Moderator
Experts Exchange
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now