|
working LDAP query, well almost.. 800A000D Hello all,
The following script should get 2 properties form the Administrator user:
"sAMAccountName" and "description".
It does display the sAMAccountName but throws an error when it tries to
display the user description.
The code:
Set objRootDSE = GetObject("LDAP://RootDSE")
strDomainDN = objRootDSE.Get("DefaultNamingContext")
Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objRSUserDescr = objConn.Execute("<LDAP://" & strDomainDN &
">;(&(objectClass=user)(sAMAccountName=Administrator));sAMAccountName,description;subtree")
WScript.echo objRSUserDescr.Fields(0).Value
WScript.echo objRSUserDescr.Fields(1).Value
The error:
this line: WScript.echo objRSUserDescr.Fields(1).Value
Error: Type Mismatch
Code: 800A000D
I tried CStr(objRSUserDescr.Fields(1).Value), but get the same error.
In my case, I cannot use GetObject("LDAP://" & UserDN) to get the user
description. I have to query AD directly.
Anyone an idea what goes wrong ?
thanks in advance,
Sander |