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 <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED] ...
> 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" < [EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > 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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to