Search-Filter for LDAP (MS Active Directory)
Tim Golden
tim.golden at viacom-outdoor.co.uk
Fri Oct 15 11:50:58 EDT 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:
http://tgolden.sc.sabren.com/downloads/active_directory.py
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"
<code>
import active_directory
ad = active_directory.AD ()
production = ad.child ("ou=production")
for computer in production.search (["objectClass=computer",
"displayName=ABC*"]):
print computer
print "Properties used:", [p for p in computer.properties if getattr
(computer, p)]
print computer.operatingSystemVersion
</code>
HTH
TJG
________________________________________________________________________
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:
http://www.star.net.uk
________________________________________________________________________
More information about the Python-list
mailing list