ADO example (Visual Basic)

This code can be found in Chapter 4 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the Visual Basic code from this site.

'# ----------------------------------------------------------------------
'# From the book "Managing Enterprise Active Directory Services"
'# ISBN: 0-672-32125-4
'# Copyright (C) 2002 by Addison-Wesley
'# Script by Robbie Allen
'# 
'# ----------------------------------------------------------------------
Dim DBC as ADODB.Connection
Dim RS as ADODB.Recordset
Set DBC = New ADODB.Connection
DBC.Open "ADSI"
Set RS = Connection.Execute("SELECT ADsPath FROM 'LDAP://dc=xyz,dc=com' WHERE sn='Doe'")
While Not RS.EOF
    Debug.Print RS.Fields("ADsPath").Value
    RS.MoveNext
Wend

This code has been viewed 3440 times.

New from the creators of TechTasks.com: StatSheet.com