I was translating my Perl LookupMailboxesFromAccount.exe to KiXtart and have run into a problem with GetInfoEX. I can not seem to to pass the proper data type to the function. See the somewhat working code below. I need to use GetInfoEx to obtain the "Home-MDB" property that is the actual server location of a mailbox.
You will see the problem line in GetMailBoxProperties($AdsPath) below. code:
$ExchangeServer="YourServer"
$Domain="YourDomain"
$Account="YourAccount"
$Mailboxes = ADOQueryAssocNTAccount($ExchangeServer, LookupHexSid($Domain, $Account))
? "Mailboxes for " + $Domain + "\" + $Account
? "------------------------------------------------------------------"
for each $mailbox in $MailBoxes
GetMailBoxProperties($Mailbox)
? "------------------------------------------------------------------"
next
Function LookupHexSid($Domain, $Account)
Dim $ADsPath, $ADsSid
$ADsPath = "WinNT://" + $Domain + "/" + $Account
$ADsSid = createobject("ADsSid")
$ADsSid.setas(5,$ADsPath)
$LookupHexSid = $ADsSid.getas(1)
EndFunction
Function ADOQueryAssocNTAccount($ExchangeServer, $HexSid)
Dim $ADOconn, $ADOQueryString, $objRS, $A, $i
$ADOconn = CreateObject("ADODB.Connection")
$ADOConn.Provider = "ADSDSOObject"
$ADOConn.Open()
if @ERROR
exit @ERROR
endif
$ADOQueryString = "<LDAP://$ExchangeServer>;(&(objectClass=person)(Assoc-NT-Account=$HEXsid));adspath;subtree";
$objRS = $ADOconn.Execute($ADOQueryString)
if VarType( $objRS ) <> 0
$i=0
Do
ReDim Preserve $A[$i]
;? $objRS.Fields("adspath").value
$A[$i] = $objRS.Fields("adspath").value
$objRS.movenext
$i=$i+1
until $objRS.EOF
$ADOQueryAssocNTAccount=$A
else
? "No MailBoxes found!"
endif
exit 0;
EndFunction
Function GetMailBoxProperties($AdsPath)
Dim $objMailBox
Dim $A[1]
$objMailBox = GetObject($ADsPath)
? "Display Name: " $objMailBox.get("cn")
? " Given Name: " $objMailBox.get("givenname")
? " Last Name: " $objMailBox.get("sn")
? " Alias: " $objMailBox.get("uid")
? "Primary SMTP: " $objMailBox.get("mail")
? " RDN: " $objMailBox.get("rdn")
? " Home MTA: " $objMailBox.get("home-mta")
; Help Please
; How does pass the required array to GetInfoEdx ???
$objMailBox.GetInfoEx("home-mdb", 0);
? "Using Text: @error @serror"
$A = "home-mdb",""
$objMailBox.GetInfoEx($A, 0);
? "Using Array: @error @serror"
? " Home MDB: " $objMailBox.get("home-mdb")
?
;? "Other Mailboxes:"
;$array=$objMailBox.get("othermailbox")
;for each $item in $array
; $type=substr($item,1,instr($item,"$$")-1)
; $address=substr($item,len($type)+2,len($item))
; ? " " $type ": "$address
;next
EndFunction
[ 03 June 2002, 22:07: Message edited by: Howard Bullock ]