Hi,
I'got problems with this script to make mailboxes on Exchange 5.5.
It give me 500 Error here:
sec.SetSecurityDescriptor sd
What can I do? Somebody has yet find this problem?
Thanks,
Fabio Bortoluzzi
<%
'--------------------------------------------------------
' Security object for SD manipulation
' (REQUIRED ADSI TOOL KIT - REGSVR32 ADSSECURITY.DLL)
'---------------------------------------------------------
Set sid = CreateObject("ADsSID")
Set sec = CreateObject("ADsSecurity")
'--------------------------------------------------------------------
' If you don't include the ADSI 2.5 Security Type Library as you make
' references, 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
'--------------------------------------------------------
' Server, Org and Site information
'
'--------------------------------------------------------
serverName = "bbb"
Org = "aaa"
Site = "AAA"
strMTA = "cn=Microsoft MTA,cn=" & serverName &
",cn=Servers,cn=Configuration,ou=" & Site & ",o=" & Org
strMDB = "cn=Microsoft Private MDB,cn=" & serverName &
",cn=Servers,cn=Configuration,ou=" & Site & ",o=" & Org
strX400 = "c=US;a= ;p=" & Org & ";o=" & Org & ";s=" & sAccount & ";"
strMember = "cn=all,cn=Recipients,ou=" & Site & ",o=" & Org
'---------------------------------------------------------------
' Creating a NT USER to be associated with the mailbox
'
'---------------------------------------------------------------
Set dom = GetObject("WinNT://" & serverName)
Set usr = dom.Create("user", sAccount)
usr.FullName = Session("sSociale")
usr.Put "userFlags", 66113
usr.SetPassword password
usr.AccountDisabled = False
usr.SetInfo
'---------------------------------------------------------------
' Build Recipient container's adsPath:
' LDAP://myserver/CN=Recipients, OU=Site, O=Org
'---------------------------------------------------------------
ADsPath = "LDAP://" + serverName
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=" & sAccount)
mailBox.Put "mailPreferenceOption", 0
'mailBox.Put "givenName", strFirstName
'mailBox.Put "sn", strLastName
mailBox.Put "uid", CStr( sAccount )
mailBox.Put "Home-MTA", strMTA
mailBox.Put "Home-MDB", strMDB
mailBox.Put "mail", sEmail
mailBox.Put "MAPI-Recipient", True
mailBox.Put "rfc822Mailbox", sEmail
mailBox.textEncodedORaddress = strX400
'mailbox.put "OtherMailbox", strOtherMailbox
mailBox.Put "memberOf", strMember
) & ")"
mailBox.Put "title", Session("sSociale")
'--------------------------------------------------------
' Associating to a primary account
' (Requires the ADSI tool kit - REGSVR32 ADSSECURITY.DLL )
'--------------------------------------------------------
sid.SetAs ADS_SID_WINNT_PATH, "WinNT://" & Org & "/" & sAccount &
",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 mailbox security ' to allow the user to
' modify a user attribute, send mail, and receive mail
'-------------------------------------------------
Set sd = sec.GetSecurityDescriptor(mailBox.ADsPath)
Set dacl = sd.DiscretionaryAcl
Set ace = CreateObject("AccessControlEntry")
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED
ace.AccessMask = ADS_RIGHT_EXCH_MODIFY_USER_ATT Or
ADS_RIGHT_EXCH_MAIL_SEND_AS Or ADS_RIGHT_EXCH_MAIL_RECEIVE_AS
ace.Trustee = Org & "\" & sAccount
dacl.AddAce ace
sd.DiscretionaryAcl = dacl
sec.SetSecurityDescriptor sd <<<<<<<<<<<<<<<------ ERROR 500
Set dom = Nothing
Set usr = Nothing
Set mailBox = Nothing
Set objCont = Nothing
Set sec = Nothing
Set sid = Nothing