I am still having difficulty with this piece of code. I have found that the function ADSearch() does not work well if the account name has a period in it, I get the IDispatch error. If the account name does not have a period in it the script below runs fine. The ADSearch function is modified slightly because I needed a different field returned.

 Code:
break ON
$test1="aber.nade" ; The period in this account name causes the IDispatch error

$str=""
$server=""
adsearch($test1)
? $str
? $server

Function ADSearch($ADAccountName)
Dim $AdoCon
dim $AdoCommand
dim $Recordset
dim $Filter
dim $homemdb
dim $store
if len($ADAccountName)>0 
      $filter=" where samAccountName='"+$ADAccountName+"' "
      $AdoCon = CreateObject("ADODB.Connection")
      $AdoCon.Provider = "ADsDSOObject"
      ; Current credentials are used, as username and password aren't specified
      $AdoCon.Open("Active Directory Provider")
      ; Create ADO command object for the connection.
      $AdoCommand = CreateObject("ADODB.Command")
      $AdoCommand.ActiveConnection = $AdoCon
      $AdoCommand.CommandText ="Select homemdb from 
'LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")+"' "+$filter
      ; Execute the query.
      $Recordset = $AdoCommand.Execute
      $homeMDB=split($recordset.fields("homemdb"),",")  ; This gives the error
      $store=split($homemdb[0],"=")
      $str=$store[1]
      $server=right($homemdb[3],4)
Else
      Exit
endif
Endfunction


Edited by Daleco (2007-04-06 07:28 AM)
_________________________
Dale