From: CParticle Date: 2006-10-04T13:05:13+09:00 Subject: Help with MS ActiveDirectory access Hey All, I'm hoping to get some help connecting to Active directory to pull down a list of user objects from the entire domain(all ou's). Let me say that while I need user objects now knowing how to get any objects from the domain would be useful as well. I've looked on the web and in the news groups including this one and not found much in the way of functional examples that I could use. My ruby version is <> installed from the one-click-installer from www.Ruby-lang.org I've installed the missing ado.rb file for DBI. Ultimately I the two things that I would like avoid though are. 1) having to recurse through the ou's one at a time to get what I need 2) any non-standard ruby modules or gems (as much as possible) I'm thinking DBI and ADO to connect to AD might be the right way but I've not seen any good examples on how to do that. I've been working on this for two and a half days so any help would be much appreciated. Below I've listed two pieces code that I've found #This code only gives me a subset of all the AD properties and doesn't use generic LDAP field names require 'win32ole' domain = WIN32OLE.connect("WinNT://corp.company.com") domain.each {|myobj| puts myobj.name if myobj.name.upcase == 'MYUSERNAME'} #This also works although this is the ldap solution and only shows one ou at a time #this would require recursion to get the whole domain require 'win32ole' rootDSE = WIN32OLE.connect("LDAP://RootDSE") domainDN = rootDSE.Get("DefaultNamingContext") #I know I'm specifying an ou but I can just uo text to an array.each pulled from the RootDSE when made recursive userContainer = WIN32OLE.connect("LDAP://ou=MyCity,ou=MyorgUnit," + domainDN) puts userContainer.each {|usr| puts usr.sAMAccountName}