Active directory users

  • Thread starter Thread starter Dr Alric
  • Start date Start date
D

Dr Alric

Hi There

I am looking for the code for a macro to be able to extract the Firstname's,
surname's and userid from our companies active directorie and put these into
an excel worksheet.

Would anybody be able to help me with this, or point me to a reference for
the syntax?

Thanks
 
or have a look at following.

How To Use ADO to Access Objects Through an ADSI LDAP Provider
http://support.microsoft.com?kbid=187529

I cant test it here... but it could look like this?

Sub LDAPviaADO()
Dim rs As Object

With CreateObject("ADODB.Connection")
.Provider = "ADSDSOObject"
.Open "ADs Provider"
'EDIT THE FOLLOWING STRING for correct settings!
Set rs = .Execute( _
"<LDAP://server/o=organization/ou=site/cn=recipients>;" _
& "(objectClass=*);ADsPath,objectClass,cn;subtree")

ActiveSheet.Cells(1).CopyFromRecordset rs
rs.Close
.Close
End With

End Sub

keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Hi There

I tried to follow the article posted, but I am still hitting a problem

this is my code

Set oTargetOU = GetObject("LDAP://DC=topics.co.za")

x = 1

oTargetOU.Filter = Array("user")

For Each usr In oTargetOU

If InStr(usr.SamAccountName, "$") = 0 Then
Cells(x, 1) = usr.get("Sn")
Cells(x, 2) = usr.get("GivenName")
x = x + 1
End If
Next

It falls over on the first line with the message:
a referral was returned from the server
Is there something wrong with my syntax or am I missing a reference
somewhere?
 
I am afraid I personally know little about Active Directory. This article
shows what to reference and what the name of the help file is - where you
should be able to get some of the information you need.

http://support.microsoft.com/default.aspx?scid=kb;en-us;194115
How To Use ADSI in VB to Enumerate the Computers in an NT Domain

ADSI Help file (ADSI.HLP)
In the ADSI Help file Contents, choose Guide - Introduction to Active
Directory Service Interfaces - Code Examples - Automation examples and
ADsPaths examples for more Visual Basic code examples.

The reference would be set to
ActiveDS

(the type library file is ActiveDS.tlb)
The Active DS Type Library provides the ADSI object model.

It has a link to these if it isn't installed on your machine.
 
Thanks
It's working now

Tom Ogilvy said:
I am afraid I personally know little about Active Directory. This article
shows what to reference and what the name of the help file is - where you
should be able to get some of the information you need.

http://support.microsoft.com/default.aspx?scid=kb;en-us;194115
How To Use ADSI in VB to Enumerate the Computers in an NT Domain

ADSI Help file (ADSI.HLP)
In the ADSI Help file Contents, choose Guide - Introduction to Active
Directory Service Interfaces - Code Examples - Automation examples and
ADsPaths examples for more Visual Basic code examples.

The reference would be set to
ActiveDS

(the type library file is ActiveDS.tlb)
The Active DS Type Library provides the ADSI object model.

It has a link to these if it isn't installed on your machine.
 

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

Back
Top