I am receiving this error when I try to create an Exchange 5.5 mailbox:
"The requested operation did not satisfy one or more constraints
associated with the class of the object. The error is happening when
the mailbox.setinfo is called. I am an administrator on the domain.
It appears that I am missing a setting somewhere. Here is the code I
am using. It comes from "ADSI Scripting for System Administration" by
Thomas Eck. I also used some code I found on Google, but had the same
results. Thanks for your input!
Dim ExchangeServerName As String
Dim ExchangeServerOrganization As String
Dim ExchangeServerSite As String
Dim Mailbox As IADs
Dim MailboxParentContainer As IADs
Dim MailboxRelativePath As String
Dim MailboxDisplayName As String
Dim MailboxFirstName As String
Dim MailboxLastName As String
Dim MailboxAlias As String
Dim MailboxMiddleInitial As String
Dim MTA As String
Dim MDB As String
Dim MailboxSMTPAddress As String
Dim MailboxX400Address As String
Dim MailboxCCMailAddress As String
Dim MailboxMSMailAddress As String
Dim NTUserAccountToAssociate As String
Dim UserDomain As String
Dim SID As New ADsSID
Dim Security As New ADsSecurity
Dim SecurityDescriptor As IADsSecurityDescriptor
Dim DiscretionaryACL As IADsAccessControlList
Dim AccessControlEntry As New AccessControlEntry
ExchangeServerName = "HSHMAIL"
ExchangeServerOrganization = "Alliance 4 Health"
ExchangeServerSite = "Holy Spirit Hospital"
MailboxRelativePath = ""
MailboxDisplayName = "Blow, Joe"
MailboxFirstName = "Joe"
MailboxLastName = "Blow"
MailboxMiddleInitial "A."
MailboxAlias = "jblow"
UserDomain = "HSHDOMAIN"
NTUserAccountToAssociate = "jblow"
MTA = "cn=Microsoft MTA,cn=" & ExchangeServerName &
",cn=Servers,cn=Configuration,ou=" & ExchangeServerSite & ",o=" &
ExchangeServerOrganization
MDB = "cn=Microsoft Private MDB,cn=" & ExchangeServerName &
",cn=Servers,cn=Configuration,ou=" & ExchangeServerSite & ",o=" &
ExchangeServerOrganization
MailboxSMTPAddress = MailboxAlias & "@" & "hsh.org"
MailboxX400Address = "c=US;a= ;p=" & "Alliance 4 Healt" & ";o=" &
ExchangeServerSite & ";s=" & MailboxLastName & ";g=" & MailboxFirstName
& ";i=" & MailboxMiddleInitial
MailboxMSMailAddress = UCase("ALLIANCE4H" & "/" & "HOLYSPIRIT" &
"/" & MailboxAlias)
Set MailboxParentContainer = GetObject("LDAP://" &
ExchangeServerName & "/o=" & ExchangeServerOrganization & "/ou=" &
ExchangeServerSite & "/cn=Recipients" & MailboxRelativePath)
Set Mailbox = MailboxParentContainer.Create("organizationalPerson",
"cn=" & MailboxAlias)
Mailbox.Put "mailPreferenceOption", 0
Mailbox.Put "givenName", MailboxFirstName
Mailbox.Put "sn", MailboxLastName
Mailbox.Put "cn", MailboxDisplayName
Mailbox.Put "uid", MailboxAlias
Mailbox.Put "Home-MTA", MTA
Mailbox.Put "Home-MDB", MDB
Mailbox.Put "mail", MailboxSMTPAddress
Mailbox.Put "MAPI-Recipient", True
Mailbox.Put "TextEncodedORaddress", MailboxX400Address
Mailbox.Put "rfc822Mailbox", MailboxSMTPAddress
Mailbox.PutEx ADS_PROPERTY_APPEND, "otherMailbox", Array("MS$" &
MailboxMSMailAddress)
SID.SetAs ADS_SID_WINNT_PATH, "WinNT://" & UserDomain & "/" &
NTUserAccountToAssociate & ",user"
sidHex = SID.GetAs(ADS_SID_HEXSTRING)
Mailbox.Put "Assoc-NT-Account", sidHex
Mailbox.SetInfo
Set SecurityDescriptor =
Security.GetSecurityDescriptor(Mailbox.ADsPath)
Set DiscretionaryACL = SecurityDescriptor.DiscretionaryACL
AccessControlEntry.AceType = ADS_ACETYPE_ACCESS_ALLOWED
AccessControlEntry.Trustee = UserDomain & "\" & MailboxAlias
AccessControlEntry.AccessMask = ADS_RIGHT_EXCH_MAIL_SEND_AS Or
ADS_RIGHT_EXCH_MAIL_RECEIVE_AS Or ADS_RIGHT_EXCH_MODIFY_USER_ATT
DiscretionaryACL.AddAce AccessControlEntry
SecurityDescriptor.DiscretionaryACL = DiscretionaryACL
Security.SetSecurityDescriptor SecurityDescriptor