Active Directory: Vbscript to enumerate all users with Outlook Web Access (owa)

Posted March 22nd, 2010 in outlookwebaccess by dirk adamsky

Outlook web access is incorporated in Active Directory through the user attribute “protocolSettings”.
Default setting is for owa is ‘enabled’. The attribute ‘protocolSettings’ has no specific entry for owa at this stage. Only when owa is explicitly denied for a specific user an entry is added, the value of this entry is:
HTTP§0§1§§§§§§. When owa is enabled again for this user the value changes to HTTP§0§0§§§§§§.
This script is tested for outlook/exchange2003.

Follow the next steps to run the script (no admin rights needed):

* open your favorite text editor
* copy and paste the script into the editor
* save the script (for example c:tempowausers.vbs)
* open a command prompt
* go to “c:temp”
* give “cscript owausers.vbs” (without quotes) and enter

The script:

' Name : owausers.vbs
' Description : script to enumerate all users with Outlook Web Access (owa)
' Author : dirk adamsky - deludi bv
' Version : 1.00
' Date : 22-03-2010
' Level : intermediate

Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection

Set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">"
Set objRootDSE = Nothing

strFilter = "(&(objectCategory=person)(objectClass=user)(mail=*)(!(cn=systemmailbox*)))"
strAttributes = "distinguishedname, mail, displayname, protocolSettings"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False

Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
	strOwa = "Yes"
	If TypeName(objRecordSet.Fields("protocolSettings").value) = "Variant()" Then
		arrProtocolsettings = objRecordSet.Fields("protocolSettings").value
		For Each Protocol in arrProtocolsettings
			If Protocol = "HTTP§0§1§§§§§§" Then
				strOWA = "No"
			End If
		Next
	End If
	Wscript.Echo objRecordSet.Fields("displayname").Value & " uses outlook web access = " & strOwa
	objRecordSet.MoveNext
Loop

objRecordSet.Close
objConnection.Close

Set objRecordSet = Nothing
Set objConnection = Nothing
Set objCommand = Nothing

When you have problems/questions please post a reply, you can also rate the script.

Happy scripting.

Best regards,

Dirk Adamsky – Deludi BV

[adrotate group="1"]