Seaching Active Directory via ADO

Rudy Schockaert rudy.schockaert at gmail.com
Fri Feb 17 01:49:13 EST 2006


You could also use the excellent active_directory module of Tim Golden (
http://tgolden.sc.sabren.com/python/active_directory.html)

Your query would then become:

import active_directory

for person in active_directory.search ("objectClass='user'","name='Roger*'"):
  print person.displayName



On 2/17/06, Roger Upole <rupole at hotmail.com> wrote:
>
> 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
> =----
> --
> http://mail.python.org/mailman/listinfo/python-list
>



--
It is not economical to go to bed early to save the candles if the result is
twins. - Chinese Proverb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060217/18b2bb72/attachment.html>


More information about the Python-list mailing list