[Tutor] iterating through large dictionary

jeff smaug9 at gmail.com
Tue Mar 22 23:00:13 CET 2005


On Tue, 22 Mar 2005 15:47:19 -0600, Christian Wyglendowski
<Christian.Wyglendowski at greenville.edu> wrote:
> > -----Original Message-----
> > From: tutor-bounces at python.org
> > [mailto:tutor-bounces at python.org] On Behalf Of jeff
> >
> > Hi,
> 
> Hey Jeff,
> 
> > I'm trying to print out all the attributes of a user account in active
> > directory. I got a script from:
> > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303348
> > /index_txt
> 
> Hhhmm... I have some code that does basically the same thing, sans the
> printing.  Mine looks up the user based on the sAMAccountName instead of
> the distinguishedName, though.
> 
> > Now I'd like it to print pretty.
> 
> [SNIP function]
> 
> > user='LDAP://cn=Wardlaw\, Jeff,OU=IS Department,OU=IT
> > department,DC=acpdom,DC=acp,DC=edu'
> > for k, v in ad_dict(user):
> >     print "%s=%s" % (k, v)
> >
> > I get the following error when I try this:
> >
> > D:\Python24>ad-attr.py
> > Traceback (most recent call last):
> >   File "D:\Python24\ad-attr.py", line 32, in ?
> >     for k, v in ad_dict(user):
> > ValueError: too many values to unpack
> 
> Try this instead ... I think it should help:
> 
> <code>
> 
> for k,v in ad_dict(user).items():
> 
> </code>

yup, that was it.

now i've got to make it pretty.

-- 
--Jeff


More information about the Tutor mailing list