View Single Post
Old 06-19-2009   #2 (permalink)
James Whitlow


 
 

Re: working LDAP query, well almost.. 800A000D

"Sander" <Sander@xxxxxx> wrote in message
news:uqN2$YP8JHA.5424@xxxxxx
Quote:

> 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 believe this property is an array. Change your line to:

WScript.echo Join(objRSUserDescr.Fields(1).Value, vbCrLf)




My System SpecsSystem Spec