[python-win32] Problems using ADSI from Python (need IDirectorySearch Interface)

Jens B. Jorgensen jens.jorgensen@tallan.com
Mon, 22 Apr 2002 09:48:41 -0500


In order to use the makepy-generated classes you just need to pass the 
already-created object as the oobj param. Here is some example code that 
works:

import ADO
from win32com.client import Dispatch

o = Dispatch('adodb.connection')
cn = ADO.Connection(oobj = o)
connection_str = 'Provider=Microsoft.Jet.OLEDB.4.0;data source=d:\\My 
Documents\\ubid\\plcc\\oracle_files\\outstanding_trans.mdb'
cn.Open(connection_str)
rs, recs = cn.Execute('select count(*) from trans')
while not rs.EOF :
    print rs.Fields(0).Value
    rs.MoveNext()


Ulrich Eck wrote:

> Hi win32 freaks,
>
> I played around a lot with ADSI using python.
>
> the standart method:
> import win32com.client
> NS = win32com.client.Dispatch('ADsNameSpaces')
> ob = NS.GetObject('','LDAP://<myldapurl>')
>
> works fine .. but I'ld like to use the static bindings
> that i created with makepy.py (examing the activeds.dll (Active DS 
> TypeLib)).
>
> i used makepy-browser from pythonwin (as well as command-line)
> to create a static-wrapper for the COM-Object and tried:
>
> import ADSI
>
>>>> ad = ADSI.IADs()
>>>
> Traceback (most recent call last):
>  File "<interactive input>", line 1, in ?
>  File "P:\Python22\\lib\site-packages\win32com\client\__init__.py", 
> line 310, in __init__
>    oobj = pythoncom.new(self.CLSID)
> com_error: (-2147221164, 'Class not registered', None, None)
>
>>>>
>
> i'm working with ActivePython 2.2 on Win2000 (already has latest ADSI)
>
> what am I doing wrong ??
>
> another thing that makes me dizzy: the pythoncom reference (shipped with
> active-python) tells about IADsUser,IADsContainer, IDirectoryObject in
> chapter modules .. but i cannot import any of these ?!?
>
> thanks for your help
>
> Ulrich Eck
> --------------------------------------------------------------------------- 
>
> net-labs Systemhaus GmbH
> Ebersberger Str. 46
> 85570 Markt Schwaben
> fon:   +49-8121-4747-11
> fax:   +49-8121-4747-77
> email: ueck@net-labs.de
> http://www.net-labs.de
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32@python.org
> http://mail.python.org/mailman/listinfo/python-win32
>


-- 
Jens B. Jorgensen
jens.jorgensen@tallan.com