Seaching Active Directory via ADO

Roger Upole rupole at hotmail.com
Thu Feb 16 20:09:29 EST 2006


Here's a short example that uses ADO to search for a
user by wildcard.

import win32com.client
c = win32com.client.Dispatch("ADODB.Connection")
c.Open("Provider=ADSDSOObject")

rs,rc=c.Execute("""
SELECT adspath, title, name
>From 'LDAP://DC=yourdomain, DC=COM'
where objectClass='user' and name='Roger*'
""")

while not rs.EOF:
    for f in rs.Fields:
        print f.Name, f.Value
    rs.MoveNext()

    hth
          Roger

"LittlePython" <LittlePython at lost.com> wrote in message
news:56aJf.78250$_D1.4370 at trnddc03...
> Thanks but I was looking more for ADO com object than ADSI or ldap.
> For some strange reason it is very hard to locate any working scripts that
> use ADO  to connect and search AD. Is there an issue with ADO and python
> when connecting to AD?
> I have try to build one myself with no luck. I think my problem is with
> adodb.command calls.
>
> Thanks for your response.
>
> "alex23" <wuwei23 at gmail.com> wrote in message
> news:1140138661.484502.86380 at f14g2000cwb.googlegroups.com...
> > Heya,
> >
> > There are a couple of examples on the O'Reilly site. These two are
> > taken from 'Active Directory Cookbook', the first uses a COM object
> > while the second uses a native LDAP module:
> >
> >
>
http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx
> t
> >
>
http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t
> xt
> >
> > This might give you a start.
> >
> > - alex23
> >
>
>



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----



More information about the Python-list mailing list