Importing a user list from AD into an Excel document

J

Jreg

Hi there;

I am trying to create an Excel document that is populated with the most
recent list of employees downloaded from our local Active Directory Server.

The following is some sample code that was used in Access to draw a field
from AD into Access. I want to know how to do something simlar to this in
which I can pull the a certain field (such as lastname) from the AD user list
and have it list them all in Excel.

cboAssignedTo.AddItem "Available"
'Get available users
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

Set conn = New ADODB.Connection
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"
Set rs = New ADODB.Recordset
rs.CursorType = adOpenStatic
rs.CursorLocation = adUseClient
rs.Open
"<LDAP://roaadsrv1.meridium.com/OU=UsersOU,DC=meridium,DC=com>;(objectClass=user);cn;subtree", conn, adOpenStatic, adLockReadOnly
rs.Sort = "cn"
While Not rs.EOF
cboAssignedTo.AddItem ("""" & rs.Fields(0).Value & """")
rs.MoveNext
Wend

conn.Close


Any help is appreciated
Jreg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top