help me: how to create a mail box automaticly using MS EXCHANGE

  • From: "EEPAD" <mohbouraoui@xxxxxxxx>
  • To: exchangelist@xxxxxxxxxxxxx
  • Date: Mon, 18 Feb 2002 07:37:18 -0700

I want to create the mail box with this script using the LDAP protocol,
and MS Exchange 2000
and my server name is EEPADEXCOM, and my organization named ORGEXCHANGE
with the administrator authantification, i seting my script:


Sub Main()

Dim sid As New ADsSID  'You can also use -- Set sid =
CreateObject("ADsSID") for late binding
Dim sec As New ADsSecurity 'You can also use -- Set sec =
CreateObject("ADsSecurity") for late binding
'-------------------------------------
'- The rest uses ADSI Interfaces
'-------------------------------------

Dim sd As IADsSecurityDescriptor
Dim dacl As IADsAccessControlList
Dim ace As New AccessControlEntry

'----------------------------------------------------------------------------

'--- If you don't include the ADSI 2.5 Security Type Library as you
reference
'--- you must manually declare the following constants
'-----------------------------------------------------------------------------

Const ADS_SID_HEXSTRING = 1
Const ADS_SID_WINNT_PATH = 5
Const ADS_RIGHT_EXCH_MODIFY_USER_ATT = &H2
Const ADS_RIGHT_EXCH_MAIL_SEND_AS = &H8
Const ADS_RIGHT_EXCH_MAIL_RECEIVE_AS = &H10


'-------------------------------------------------------
'-----CREATING A MAILBOX  ----------------------
'--------------------------------------------------------

'---- Server, Org and Site information
Server = "EEPADEXCOM"
Org = "ORGEXCHANGE"
Site = "Default-First-Site"
Domain = "EEPADEX"
UserName = "claud"
password = "claud"

'--- MailBox Parameters -----
strDisplayName = "claud"
strFirstName = "flis"
strLastName = "claud"
strAlias = UserName


strMTA = "cn=Microsoft MTA,cn=" & server &
",cn=Servers,cn=Configuration,ou=" & Site & ",o=" & Org
strMDB = "cn=Microsoft Private MDB,cn=" & server &
",cn=Servers,cn=Configuration,ou=" & Site & ",o=" & Org

strSMTPAddr = "claud@xxxxxxxxxxxxxxxx"
'------ Creating an NT user to be associated with the mail box
Set dom = GetObject("WinNT://" & Domain)
Set usr = dom.Create("user", UserName)
usr.SetInfo
usr.SetPassword password

ADsPath = "LDAP://"; + server
ADsPath = ADsPath + "/cn=Recipients,OU="
ADsPath = ADsPath + Site
ADsPath = ADsPath + ",O="
ADsPath = ADsPath + Org


Set objCont = GetObject(ADsPath)

'Create a new MailBox
Set Mailbox = objCont.Create("organizationalPerson", "cn=" & strAlias)
Mailbox.Put "mailPreferenceOption", 0
Mailbox.Put "givenName", strFirstName
Mailbox.Put "sn", strLastName
Mailbox.Put "cn", strDisplayName
Mailbox.Put "uid", strAlias
Mailbox.Put "Home-MTA", strMTA
Mailbox.Put "Home-MDB", strMDB
Mailbox.Put "mail", strSMTPAddr
Mailbox.Put "MAPI-Recipient", True
Mailbox.Put "rfc822Mailbox", strSMTPAddr

'--------------------------------------------------------
'  ASSOCIATING TO NT PRIMARY ACCOUNT
' (REQUIRED 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
'-------------------------------------------------
'--- SET THE MAIL BOX SECURITY ------------------
'-- To allow the user to modify user attribute, send mail and receive mail
'-------------------------------------------------
Set sd = sec.GetSecurityDescriptor(Mailbox.ADsPath)
Set dacl = sd.DiscretionaryAcl
ace.Trustee = Domain & "\" & strAlias
ace.AccessMask = ADS_RIGHT_EXCH_MODIFY_USER_ATT Or
ADS_RIGHT_EXCH_MAIL_SEND_AS Or ADS_RIGHT_EXCH_MAIL_RECEIVE_AS
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED
dacl.AddAce ace
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd
End Sub


but the system signaled this error  "run-time -2147016672 (80072020)
automation error An operations error occured"
and the debug Point at thi line: Set objCont = GetObject(ADsPath) 
what is a cause of error? please help me! and Thanks for any information
 

 


Other related posts:

  • » help me: how to create a mail box automaticly using MS EXCHANGE