Gitcho
asked on
ASP LDAP Query
Hey all ... can't seem to pull a few attributes from AD ... this query works :
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -------
<LDAP://domain.com>;(&(obj ectCategor y=person)( objectClas s=user)(sA MAccountNa me=JSmith) );sn,given Name,sAMAc countName, department ,ADsPath;s ubtree
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -------
... but as soon as I change the attributes and add any one of these: "description", "office", or "phone", it errors out :
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -------
<LDAP://domain.com>;(&(obj ectCategor y=person)( objectClas s=user)(sA MAccountNa me=JSmith) );sn,given Name,sAMAc countName, department ,ADsPath,d escription ,office,ph one;subtre e
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -------
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 ?
--------------------------
<LDAP://domain.com>;(&(obj
--------------------------
... but as soon as I change the attributes and add any one of these: "description", "office", or "phone", it errors out :
--------------------------
<LDAP://domain.com>;(&(obj
--------------------------
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 ?
ASKER
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch
LDAP.asp, line 134
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- -
strAttributes = "sn,description,givenName, sAMAccount Name,depar tment,ADsP ath"
arrAttributes = split(strAttributes,",")
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Pag e Size") = 100
objCommand.Properties("Tim eout") = 30
objCommand.Properties("Cac he Results") = False
objCommand.Properties("Sor t 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'?><ro ot></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(arrAtt ributes(i) ) & "</" & arrAttributes(i) & ">" & vbNewline
Next
XMLtext = XMLtext & "</user>" & vbNewLine
objRecordSet.MoveNext
Loop
XMLtext = XMLtext & "</xml>"
Microsoft VBScript runtime (0x800A000D)
Type mismatch
LDAP.asp, line 134
--------------------------
strAttributes = "sn,description,givenName,
arrAttributes = split(strAttributes,",")
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Pag
objCommand.Properties("Tim
objCommand.Properties("Cac
objCommand.Properties("Sor
Set objRecordSet = objCommand.Execute
If objRecordSet.EOF Then
'return empty if result set empty
XMLUserData = "<?xml version='1.0' encoding='ISO-8859-1'?><ro
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(arrAtt
Next
XMLtext = XMLtext & "</user>" & vbNewLine
objRecordSet.MoveNext
Loop
XMLtext = XMLtext & "</xml>"
OK another question. Which line is 134?
JM
JM
ASKER
oh ... sorry ...
XMLtext = XMLtext & "<" & arrAttributes(i) & ">" & objRecordSet.Fields(arrAtt ributes(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.
XMLtext = XMLtext & "<" & arrAttributes(i) & ">" & objRecordSet.Fields(arrAtt
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.
ASKER
i figured it out ... "description", "office", and "phone" are multi-valued items (arrays), and can't be referred to directly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JM