Jeg rodede med noget lignende en gang, men fandt aldrig de vise sten.
I stedet lavede jeg et VBScript som fylder data i en tabel
Du kan se feltnavnene nedenfor og tabellen hedder ADUsers.mdb - måske skal du rette i scriptet så det har den fulde sti med til databasen.
Du skal selvfølgelig også rette dc=DOMAINNAME til det rigtige domæne
On Error Resume Next
Dim objcommand
Dim objconnection
Dim strquery
Dim strdbpath
Dim objrecordset
Dim objaccessconnection
Dim objaccessrecordset
Dim objitem
Const ADS_UF_ACCOUNTDISABLE = 2
Const adLockOptimistic = 3
' - Connect to AD
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strQuery = "<
LDAP://dc=DOMAINNAME,dc=local>;(objectCategory=person);" & "adsPath;subtree"
objCommand.CommandText = strQuery
Set objRecordSet = objCommand.Execute
' - Open Access DB
Set objAccessConnection = CreateObject("ADODB.Connection")
Set objAccessRecordset = CreateObject("ADODB.Recordset")
strDBPath = "ADUsers.mdb"
objAccessConnection.open ("DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & strDBPath)
Set objAccessRecordset.ActiveConnection = objAccessConnection
objAccessRecordset.LockType = adLockOptimistic
' - delete all of the rows from the DB and populate it anew.
objAccessRecordset.source = "DELETE * FROM ADUsers"
objAccessRecordset.Open
' - now open one that we can use
objAccessRecordset.source = "Select * FROM ADUsers"
objAccessRecordset.Open
' - Loop through all of the users and insert their details into the DB
Do Until objRecordSet.EOF
Set objItem = GetObject(objRecordSet.Fields ("adspath"))
objAccessRecordset.AddNew
objAccessRecordset.Fields("DisplayName") = objItem.displayName
objAccessRecordset.Fields("UserID") = objItem.sAMAccountName
objAccessRecordset.Fields("EmailAddress") = objItem.mail
If objitem.userAccountControl And ADS_UF_ACCOUNTDISABLE Then
objAccessRecordset.Fields("UserDisabled") = True
Else
objAccessRecordset.Fields("UserDisabled") = False
End If
objAccessRecordset.Update
objRecordSet.MoveNext
Loop