PDA

View Full Version : LogParser and ADSI - Example Code



stanl
01-03-2010, 08:53 AM
Have an Active Directory then check this out (you must have Logparser 2.2 installed, but it is free from Microsoft). It outputs to the LogParser datagrid, but you can easily chose another output format like .csv or choose COM output and move the data directly into a db table or spreadsheet.


Sub getmembers()
Dim oLog, oInput, oOut, cSQL
Set oLog = CreateObject("MSUtil.LogQuery")
oLog.maxParseErrors = 100
Set oInput = CreateObject("MSUtil.LogQuery.ADSInputFormat.1")
oInput.ObjClass = "user"
Set oOut = CreateObject("MSUtil.LogQuery.DataGridOutputFormat.1")
cServer = "myServer"
cDC = "myDomain"
cDC1 = "com" 'or net
cSQL = "SELECT cn,memberOF INTO DATAGRID FROM LDAP://" & cServer & "/DC=" & cDC & ",DC=" & cDC1
oLog.ExecuteBatch cSQL, oInput, oOut
Set oOut = Nothing
Set oInput = Nothing
Set oLog = Nothing
End Sub


Stan

stanl
01-09-2010, 01:57 PM
bummer :think: no Active Directory people out there.