Search-Filter for LDAP (MS Active Directory)

Tim Golden tim.golden at
Fri Oct 15 17:50:58 CEST 2004

| I asked here a few weeks ago the same question but the answer of Tim
| Golden didn't really help yet.
| I'd like to know how to set up a query for all computer-accounts in a
| special part of Active Directory by using LDAP.

OK. I imagine that this is far too late to solve your particular
problem, and several others have already provided LDAP-based solutions
but... I've uploaded a module-wrapper round Microsoft's LDAP:// object
set to:

I'll try to put some info on that site to support it, but
it's fairly simple, fairly well-commented within, and I'll
add an example below to match your situation.

| Example:
| all computers with a name like "ABC*" at "..., ou=Production,
| DC=business,DC=company,DC=com"

import active_directory
ad = active_directory.AD ()
production = ad.child ("ou=production")

for computer in (["objectClass=computer",
  print computer
  print "Properties used:", [p for p in if getattr
(computer, p)]
  print computer.operatingSystemVersion



This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

More information about the Python-list mailing list