[Tutor] ADO problem
Tim Golden
mail at timgolden.me.uk
Mon Jul 16 14:16:54 CEST 2007
János Juhász wrote:
> while not rs.EOF:
> print rs.Fields[0].Value, rs.Fields[1].Value
> rs.MoveNext()
>
> It print the next result:
> IT (u'\xc1kos Szab\xf3',)
> IT (u'Szabolcs K\xe1m\xe1n',)
> ...
>
> So rs.Fields[1] is a tuple.
Well, here's the most obvious thing:
By the look of it: rs.Fields[1] is *not* a tuple.
It's an instance of some sort. rs.Fields[1].Value
*is* a tuple. So something like this:
rs.Fields[1].Value[0]
should work. I'm not quite clear why that second
field returns a tuple while the first one doesn't.
(Assuming you have reproduced the code and output
faithfully).
To do this specific thing, you might find it easier
to use a module wrapper:
http://tgolden.sc.sabren.com/python/active_directory.html
where your query would become something like (untested):
<code>
import active_directory
for user in active_directory.search (
objectClass="User",
name="*.ferbeau",
department="IT"
):
print user.name, user.description, user.department
</code>
Hope that helps somewhat.
TJG
More information about the Tutor
mailing list