VBS Script to export properties of all groups in IBM Lotus Domino using LDAP

The attached script will extract the common name and email address of every group stored within a domino directory to a CSV file.

You will need to change the dominoserver within the select statement to the name of your server, you may also need to fill in the User ID and Password fields if you servers does not allow anonymous access.

You domino server will also need to accessible via LDAP.

Const ADS_SCOPE_SUBTREE = 2

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
Set objCommand = CreateObject("ADODB.Command")
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "" 'If required: Enter a domino user in the form "Test User/ou/org"
objConnection.Properties("Password") = "" 'If required: Enter the users password
objConnection.Properties("Encrypt Password") = False
objConnection.Open "ADs Provider"
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000

'The query: change dominoserver to the name of your domino server
objCommand.CommandText = "SELECT * FROM 'LDAP://dominoserver' WHERE objectClass='dominoGroup' AND mail='*'"

'Prepare the report file
currentScriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
reportFile = currentScriptPath & "Domino_Groups.csv"
Set objReportFile = objFSO.CreateTextFile(reportFile, ForWriting)

'Execute the ldap query
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
        Set objUser = GetObject(objRecordSet.Fields("ADsPath").Value)
       
        strMail = objUser.mail
        strCN = objUser.cn
       
        'Build the ouput string "cn", "email"
        outputString =  chr(34) & strCN & chr(34) & ", " &  chr(34) & strMail & chr(34) & chr(13) & chr(10)
               
        'Write to file
        objReportFile.Write(outputString)
       
        'Move to the next group
        objRecordSet.MoveNext
Loop

'Close the report file
objReportFile.Close

'Notify we are complete
wscript.echo "Complete."

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.