You could also use the excellent active_directory module of Tim Golden (<a href="http://tgolden.sc.sabren.com/python/active_directory.html">http://tgolden.sc.sabren.com/python/active_directory.html</a>)<br><br>Your query would then become:
<br><br><pre>import active_directory<br><br>for person in active_directory.search ("objectClass='user'","name='Roger*'"):<br> print person.displayName<br><br></pre><br><br><div><span class="gmail_quote">
On 2/17/06, <b class="gmail_sendername">Roger Upole</b> <<a href="mailto:rupole@hotmail.com">rupole@hotmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Here's a short example that uses ADO to search for a<br>user by wildcard.<br><br>import win32com.client<br>c = win32com.client.Dispatch("ADODB.Connection")<br>c.Open("Provider=ADSDSOObject")<br><br>rs,rc=
c.Execute("""<br>SELECT adspath, title, name<br>>From 'LDAP://DC=yourdomain, DC=COM'<br>where objectClass='user' and name='Roger*'<br>""")<br><br>while not rs.EOF:<br> for f in rs.Fields
:<br> print f.Name, f.Value<br> rs.MoveNext()<br><br> hth<br> Roger<br><br>"LittlePython" <<a href="mailto:LittlePython@lost.com">LittlePython@lost.com</a>> wrote in message<br>news:56aJf.78250$_D1.4370@trnddc03
...<br>> Thanks but I was looking more for ADO com object than ADSI or ldap.<br>> For some strange reason it is very hard to locate any working scripts that<br>> use ADO to connect and search AD. Is there an issue with ADO and python
<br>> when connecting to AD?<br>> I have try to build one myself with no luck. I think my problem is with<br>> adodb.command calls.<br>><br>> Thanks for your response.<br>><br>> "alex23" <
<a href="mailto:wuwei23@gmail.com">wuwei23@gmail.com</a>> wrote in message<br>> news:1140138661.484502.86380@f14g2000cwb.googlegroups.com...<br>> > Heya,<br>> ><br>> > There are a couple of examples on the O'Reilly site. These two are
<br>> > taken from 'Active Directory Cookbook', the first uses a COM object<br>> > while the second uses a native LDAP module:<br>> ><br>> ><br>><br><a href="http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx">
http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_com.py.tx</a><br>> t<br>> ><br>><br><a href="http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t">http://www.rallenhome.com/books/adcookbook/src/18.6-rootdse_python_ldap.py.t
</a><br>> xt<br>> ><br>> > This might give you a start.<br>> ><br>> > - alex23<br>> ><br>><br>><br><br><br><br>----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
<br><a href="http://www.newsfeeds.com">http://www.newsfeeds.com</a> The #1 Newsgroup Service in the World! 120,000+ Newsgroups<br>----= East and West-Coast Server Farms - Total Privacy via Encryption =----<br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">
http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br><br clear="all"><br>-- <br>It is not economical to go to bed early to save the candles if the result is twins. - Chinese Proverb <br>