J
james_keegan via AccessMonster.com
Hey Folks:
I'm trying to get a table in Access populated with user-ID's, names, e-mail
phone and other data from the Active Directory via an ldap-query.
I got a VBS script to get to the AD tables, and return the appropriate
recordset (with some help from 'The Scripting Guy' over at MSDN).
***
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = 2
objCommand.CommandText = "SELECT sAMAccountName, givenName, sn,
telephonenumber, title, department, physicaldeliveryofficename, mail FROM
'LDAP://HSEN/OU=Tompkins County DSS (A50), OU=Counties,OU=All Users and
Computers,DC=HSEN' WHERE objectCategory='user' "
Set objRecordSet = objCommand.Execute
***
But I can't figure out how to do the same thing from within an Access VB
module.
My attempt based on stuff I've seen here fails almost immediately:
***
Dim objConnection As Object
Dim objRecordset As Object
Dim objCommand As Object
objConnection = CreateObject("ADODB.Connection")
***
Fails at the "adodb.connection" line with an "Invalid outside procedure"
message.
I've added the 'Microsoft Activex Data Objects 2.8 Library" from the tools-
resources menu, so that wasn't it.
How can I acomplish what I want to do here? Or should I be using the VBS
script to populate the Access table? How do I reference the Access table
from the VBS script if that's the right way to go?
I would prefer to do this all within Access if that's possible, so that
whenever the database was opened, the table would refresh from the lasted AD
data. Otherwise, I'd have to write a batch file and call the vbscript, and
then call the access database.
Any clues would be most appreciated!
Thanks.
jk
I'm trying to get a table in Access populated with user-ID's, names, e-mail
phone and other data from the Active Directory via an ldap-query.
I got a VBS script to get to the AD tables, and return the appropriate
recordset (with some help from 'The Scripting Guy' over at MSDN).
***
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = 2
objCommand.CommandText = "SELECT sAMAccountName, givenName, sn,
telephonenumber, title, department, physicaldeliveryofficename, mail FROM
'LDAP://HSEN/OU=Tompkins County DSS (A50), OU=Counties,OU=All Users and
Computers,DC=HSEN' WHERE objectCategory='user' "
Set objRecordSet = objCommand.Execute
***
But I can't figure out how to do the same thing from within an Access VB
module.
My attempt based on stuff I've seen here fails almost immediately:
***
Dim objConnection As Object
Dim objRecordset As Object
Dim objCommand As Object
objConnection = CreateObject("ADODB.Connection")
***
Fails at the "adodb.connection" line with an "Invalid outside procedure"
message.
I've added the 'Microsoft Activex Data Objects 2.8 Library" from the tools-
resources menu, so that wasn't it.
How can I acomplish what I want to do here? Or should I be using the VBS
script to populate the Access table? How do I reference the Access table
from the VBS script if that's the right way to go?
I would prefer to do this all within Access if that's possible, so that
whenever the database was opened, the table would refresh from the lasted AD
data. Otherwise, I'd have to write a batch file and call the vbscript, and
then call the access database.
Any clues would be most appreciated!
Thanks.
jk