Hello,

I'm playing around with an example i found in the ADSI sdk doc. (ADSI Exchange programmer's guide --> Advanced Shema Concepts --> Visual basic usage examples --> Creating a Mailbox with IADsSecurityDescriptor and IADsSID in the ADSI Resource Kit)

The NT user creation part goes ok but the mailbox part not. The following piece of code have i created for making a mailbox.

code:
;--- MailBox Parameters ---
$strDisplayName = "John Smith"
$strFirstName = "John"
$strLastName = "Smith"
$strAlias = $userName
;$strMTA = "cn=Microsoft MTA,cn=$server,cn=Servers,cn=Configuration,ou=$Site,o=$Org"
$strSMTPAddr = "jan.smith@@gispen.nl"

;---------------------------------------------------------------
; Build Recipient container's adsPath:
; LDAP://myserver/CN=Recipients, OU=Site, O=Org
;---------------------------------------------------------------
$ADsPath = "LDAP://MyServer/cn=Recipients,ou=Site,o=Organisation"
$objCont = $GetObject($ADsPath)
? @SERROR

;---Create a new MailBox---
$mailBox = $objCont.Create($strAlias)
? @SERROR
$mailBox.mailPreferenceOption = "0"
? @SERROR
$mailBox.givenName = $strFirstName
? @SERROR
$mailBox.sn = $strLastName
? @SERROR
$mailBox.cn = $strDisplayName
? @SERROR
$mailBox.uid = $strAlias
? @SERROR
;$mailBox.Home-MTA = $strMTA
? @SERROR
;$mailBox.Put "Home-MDB", strMDB
$mailBox.mail = $strSMTPAddr
? @SERROR
;$mailBox.Put "MAPI-Recipient", True
$mailBox.rfc822Mailbox = $strSMTPAddr
? @SERROR

;--------------------------------------------------------
; Associating to a primary account
; (Requires the ADSI tool kit - REGSVR32 ADSSECURITY.DLL )
;--------------------------------------------------------
;sid.SetAs ADS_SID_WINNT_PATH, "WinNT://" & domain & "/" & strAlias & ",user"
;sidHex = sid.GetAs(ADS_SID_HEXSTRING)
;mailBox.Put "Assoc-NT-Account", sidHex

; Commit the property cache to the directory service
$mailBox.SetInfo
? @SERROR
$mailbox = ""

During the $mailbox.xxx = $Variable section i get all kind of Invalid Handle error.

code:
The operation completed successfully.LDAP://MyServer/cn=Recipients,ou=Site,o=Organisation
The operation completed successfully.smithj
The handle is invalid.0
The handle is invalid.John
The handle is invalid.Smith
The handle is invalid.John Smith
The handle is invalid.smithj
The handle is invalid.
The handle is invalid.jan.smith@gispen.nl
The handle is invalid.jan.smith@gispen.nl
The handle is invalid.
The handle is invalid.

Anyone an idea what i'm doing wrong?

The account i use to create the user has all rights in Exchange from top to bottom

@Kix = 4.12
OS = NT 4
_________________________
regards, Martijn