her er der et eksemepl på hvordan man vha. CDOEX og ADSI opretter en bruger med en tilhørende mailbox.
Sub ADSICreateMailBoxRecipient(DCServer As String, _
DomainName As String, _
emailname As String, _
FirstName As String, _
LastName As String)
'DCServer is something like "DCServer6"
'DomainName is something like "DC=MYDOMAIN3,DC=microsoft,DC=com"
'emailname is something like "jamessmith"
'this assumes the MDB to be a mailbox store
Dim objUser
Dim objContainer
Dim objMailbox
Dim recipname, recip
recip = "CN=" & emailname
' get the container
Set objContainer = GetObject("
LDAP://" + DCServer + "/" + _
"CN=users," + DomainName)
' create a recipient
Set objUser = objContainer.Create("User", recip)
objUser.Put "samAccountName", emailname
objUser.Put "sn", LastName
objUser.Put "givenName", FirstName
objUser.Put "userPrincipalName", emailname
objUser.SetInfo
objUser.SetPassword "password" 'user should change this later
objUser.AccountDisabled = False
Set objMailbox = objUser
'Create a mailbox for the recipient
'You cannot create a mailbox using ADSI, so use CDOEXM
'These values will differ for other organizations
objMailbox.CreateMailbox "
LDAP://" + DCServer + _
"/CN=Private MDB" + _
",CN=First Storage
Group,CN=InformationStore,CN=" + _
DCServer + _
",CN=Servers,CN=First Administrative Group,"
+ _
"CN=Administrative Groups,CN=First
Organization," + _
"CN=Microsoft Exchange,CN=Services," + _
"CN=Configuration," + DomainName
objUser.SetInfo
End Sub
Håber det kan bruges :-)
VH CK