VBScript: read Exchange 2003 mailbox permissions
Some time ago I made a VBScript to read the Exchange mailbox permissions, as stored in the msExchMailboxSecurityDescriptor property of a user object. This time the script is more targeted towards reading which user account have full mailbox access, and exporting them to a CSV file:
strUserODN = wscript.arguments(0)
strOutput = wscript.arguments(1)
strDomainController = wscript.arguments(2)
Const RIGHT_DS_DELETE = &H10000
Const RIGHT_DS_READ = &H20000
Const RIGHT_DS_CHANGE = &H40000
Const RIGHT_DS_TAKE_OWNERSHIP = &H80000
Const RIGHT_DS_MAILBOX_OWNER = &H1
Const RIGHT_DS_SEND_AS = &H2
Const RIGHT_DS_PRIMARY_OWNER = &H4< Const ADS_ACETYPE_ACCESS_ALLOWED = &H0 Const ADS_ACETYPE_ACCESS_DENIED = &H1 set fso = CreateObject(“Scripting.FileSystemObject”) set csvOutput = fso.CreateTextFile(strOutput, true) Set objSdUtil = GetObject(“LDAP://” & strDomainController & “/” & strUserODN & “”) Set objsd = objSdUtil.Get(“msExchMailboxSecurityDescriptor”) Set objDACL = objsd.DiscretionaryAcl For Each objACE in objDACL if (objACE.AccessMask and RIGHT_DS_MAILBOX_OWNER) then if (objACE.AccessMask and RIGHT_DS_READ) then csvOutput.WriteLine objAce.Trustee end if end if Next