set objRootDSE = getobject("LDAP://RootDSE")
strExportFile = "C:\MyExport.xls"
strRoot = objRootDSE.Get("DefaultNamingContext")
strfilter = "(&(objectCategory=Person)(objectClass=User)(department=brugere))"
strfilter = "(&(objectCategory=Person)(objectClass=User))"
strAttributes = "sAMAccountName,userPrincipalName,givenName,sn,"
strScope = "subtree"
set cn = createobject("ADODB.Connection")
set cmd = createobject("ADODB.Command")
cn.open "Provider=ADsDSOObject;"
cmd.ActiveConnection = cn
cmd.commandtext = "<LDAP://" & strRoot & ">;" & strFilter & ";" & _
strAttributes & ";" & strScope
set rs = cmd.execute
set objExcel = CreateObject("Excel.Application")
set objWB = objExcel.Workbooks.Add
set objSheet = objWB.Worksheets(1)
For i = 0 To rs.Fields.Count - 1
objSheet.Cells(1, i + 1).Value = rs.Fields(i).Name
objSheet.Cells(1, i + 1).Font.Bold = True
Next
objSheet.Range("A2").CopyFromRecordset(rs)
' Save the workbook
objWB.SaveAs(strExportFile)
rs.close
cn.close
set objSheet = Nothing
set objWB = Nothing
objExcel.Quit()
set objExcel = Nothing
ASKER
Active Directory (AD) is a Microsoft brand for identity-related capabilities. In the on-premises world, Windows Server AD provides a set of identity capabilities and services, and is hugely popular (88% of Fortune 1000 and 95% of enterprises use AD). This topic includes all things Active Directory including DNS, Group Policy, DFS, troubleshooting, ADFS, and all other topics under the Microsoft AD and identity umbrella.
TRUSTED BY
I am afraid you have to buy that... you didn't indicate though whether you want to just view and print the user logons OR whether you want to incorporate it into an application you are developing... I assume the former. If it is not what you want, pls let us know.