[python-win32] ADSI and LDAP Searches
Gooch, John
John.Gooch at echostar.com
Thu Dec 8 18:22:17 CET 2005
I am trying to get my Python script to search Active Directory for users
with a certain login name and then have it return their adspath
attribute. Previously, I had a working script that used Tim Golden's
active_directory module, but since the more recent round of NT Server
patches, it no longer works, so now I am trying to make a work around to
this issue.
Here is what I have that is working ( in my test script ):
________________________________
import win32com.client
username = "John.Gooch"
adsi = win32com.client.Dispatch('ADsNameSpaces')
ldap = adsi.getobject('','LDAP:')
DSO = ldap.OpenDSObject( "LDAP://MER2-ECHDC2.echostar.com","","", 1)
_________________________________
It works up to here, so now I assume I am connected to Active Direcory
and can now run an LDAP-style search:
_________________________________
DSO.execute("<LDAP://ou=echostar,ou=com>;(cn=*);adspath;top")
_________________________________
Ok,no go on that line( throws error "AttributeError: <unknown>.execute"
, but then I am complete guessing the syntax based upon an old Perl
script I had that used to do this job.
Does anyone have a working example of searching Active Directory? Of you
course you can put in made up domain/server names where necessary.
Thank You,
John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Englewood, CO 80112
Desk: 720-514-5708
More information about the Python-win32
mailing list