Setting Message Restriction on an SMTP Virtual Server Using ADSI
Setting Message Restriction on an SMTP Virtual Server Using ADSI
This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Visual Basic
'Set message restriction on SMTP Virtual Server using ADSI 'This sample will set the message restriction for all of the virtual 'SMTP servers in an administrative group in an organization. 'To simplify the sample you must set the value of strOrg to an Organization 'Name and set the value of strAdmiGrp to an administrative group 'By default an Exchange server will have an administrative group 'called First Administrative Group. Sub SetMsgRestriction() Dim oRootDSE As IADs Dim oConnection As New ADODB.Connection Dim oCommand As New ADODB.Command Dim oRecordSet As ADODB.Recordset Dim oRecordSet2 As ADODB.Recordset Dim varConfigNC As Variant Dim strQuery As String Dim strOrg As String Dim strAdminGrp As String On Error Resume Next 'TODO: set these next two variables strOrg = "Microsoft" strAdminGrp = "First Administrative Group" ' Get the configuration naming context Set oRootDSE = GetObject("LDAP://RootDSE") varConfigNC = oRootDSE.Get("configurationNamingContext") ' Open the Connection oConnection.Provider = "ADsDSOObject" oConnection.Open "ADs Provider" oCommand.ActiveConnection = oConnection oCommand.Properties("Page Size") = 99 strQuery = "<LDAP://CN=Servers,CN=" & _ strAdminGrp & ",CN=Administrative Groups,CN=" & _ strOrg & ",CN=Microsoft Exchange,CN=Services," & _ varConfigNC & _ ">;(objectCategory=msExchExchangeServer);distinguishedname;subtree" oCommand.CommandText = strQuery 'Get a recordset of all the servers Set oRecordSet = oCommand.Execute 'Iterate through the Servers 'check for errors If Err.Number = 0 Then While Not oRecordSet.EOF ' Build the query to find all Virtual SMTP Servers on each Server in the strAdminGroup Err.Number = 0 strQuery = "<LDAP://cn=SMTP,cn=Protocols," _ & oRecordSet("distinguishedname").Value & _ ">;(|(objectCategory=protocolCfgSharedServer)(objectCategory=protocolCfgSMTPServer));distinguishedname;subtree" Debug.Print strQuery oCommand.ActiveConnection = oConnection 'reset the error to null so we can check it later. Err.Number = 0 oCommand.CommandText = strQuery Set oRecordSet2 = oCommand.Execute 'if a recordset was returned..... If Err.Number = 0 Then 'Iterate through the Virtual SMTP Servers While Not oRecordSet2.EOF ADsPath = "LDAP://" & oRecordSet2("distinguishedname").Value Set oSMTP = GetObject(ADsPath) Debug.Print oSMTP.msExchSmtpMaxMessageSize 'set the Maximume Message size to 5000 KB or 5120000 bytes oSMTP.Put "msExchSmtpMaxMessageSize", 5120000 oSMTP.SetInfo ' other properties of interest : 'msExchSmtpMaxMessageSize - Limit message size to (KB) 'msExchSmtpMaxSessionSize - Limit session to (KB) 'msExchSmtpMaxOutboundMsgPerDomain - Limit messages per connection 'msExchSmtpMaxRecipients - Limit number of recipient per message 'msExchSmtpSendNDRTo - Send copy of Non-Delivery report to 'msExchSmtpQueueDirectory - BadmailDirectory 'msExchAlternateServer - Forward all mail with unresolved recipients to host. 'msExchMaxIncomingConnections - Limit number of connection to 'msExchServerBindings IP Address 'msExchServerBindingTurflist Enable Filter Turf List 'msExchIncomingConnectionTimeout - Connection time-out (minutes) 'msExchLogType - Enable Logging 'msExchAuthenticationFlags - Access Control 'msExchIPSecurity - Connection control 'msExchSMTPRelayIpList - Relay IP restictions list 'msExchSmtpRemoteQueueRetries - Delivery Outbound retries 'msExchSmtpRemoteQueueDelayNotification - Delivery outbound delay notification 'msExchSmtpRemoteQueueExpirationTimeout - Delivery outbound expiration timeout 'msExchSmtpLocalQueueDelayNotification - Delivery Local delay notification 'msExchSmtpRemoteQueueExpirationTimeout - Delivery Local expiration timeout oRecordSet2.MoveNext Wend oRecordSet2.Close End If oRecordSet.MoveNext Wend Else Debug.Print "Bad information for strOrg = " & strOrg & " or for strAdminGrp =" & strAdminGrp End If 'Clean Up oRecordSet.Close oConnection.Close Set oRecordSet = Nothing Set oRecordSet2 = Nothing Set oCommand = Nothing Set oConnection = Nothing End Sub
Send us your feedback about the Microsoft Exchange Server 2003 SDK.
Build: June 2007 (2007.618.1)
© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.