Option Explicit
'**************Items to be changed***********************************
' Change the value to set the base LDAP path
Const sConfigPath = "ou=Users,ou=Asia Pacific,dc=contoso,dc=com"
' Change the value to set the Domain Controller name
Const sADDC = "DCW2K3"
' Change the value to set the Exchange 2003 Server name
Const sExchangeServer = "EX2K3"
'********************************************************************
Dim oFSO
Dim sOutputFile
Dim oOutputFile
Dim oConnAD
Dim oComAD
Dim oRSAD
Dim sADQuery
Dim oADUser
Dim HomeServer
Dim DName
'Create the File System and AD object references
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set oConnAD = WScript.CreateObject("ADODB.Connection")
'Create output file to see what objects were modified.
sOutputFile = "MsgLimit.txt"
Set oOutputFile = oFSO.OpenTextFile(sOutputFile, 8, True)
'Define and open the ADO provider for connecting to AD
oConnAD.Provider = "ADsDSOObject"
oConnAD.Open "ADs Provider"
'Build the AD query to find only users and groups that are mailbox-enabled
'then return the values of the properties defined at the tail end of the query string.
sADQuery = "<LDAP://" & sADDC & "/" & sConfigPath & ">;(&(objectClass=user)(objectCategory=person)(mailNickname=*))" &
";adspath,distinguishedName,displayName,msExchHomeServerName,delivContLength,submissionContLength;subtree"
'Set the connection properties for the AD query
Set oComAD = WScript.CreateObject("ADODB.Command")
oComAD.ActiveConnection = oConnAD
oComAD.Properties("Page Size") = 500
oComAD.CommandText = sADQuery
'Execute the AD query
Set oRSAD = WScript.CreateObject("ADODB.Recordset")
Set oRSAD = oComAD.Execute
'Loop through each AD users found
While Not oRSAD.EOF
Dname = oRSAD.Fields("displayName")
HomeServer = oRSAD.Fields("msExchHomeServerName")
If HomeServer <> "" Then
HomeServer = Mid(HomeServer,InStrRev(HomeServer, "=")+1)
End If
If HomeServer = sExchangeServer Then
Set oADUser = GetObject(oRSAD.Fields(0).Value)
oADUser.delivContLength = 8192
oADUser.submissionContLength = 8192
oADUser.SetInfo
Wscript.Echo DName & vbTab & HomeServer & vbTab & oRSAD.Fields("delivContLength") & vbTab &
oRSAD.Fields("submissionContLength")
oOutputFile.WriteLine DName & vbTab & HomeServer & vbTab & oRSAD.Fields("delivContLength") & vbTab &
oRSAD.Fields("submissionContLength")
End If
oRSAD.MoveNext
Wend
'Clean up.
oOutputFile.Close
oRSAD.Close
oConnAD.Close
Set oRSAD = Nothing
Set oComAD = Nothing
Set oConnAD = Nothing