Hi,

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

Now I'd like it to print pretty.

What I have now is:

import win32com,win32com.client

def ad_dict(ldap_path,value_required=1):
  attr_dict={}
  adobj=win32com.client.GetObject(ldap_path)
  schema_obj=win32com.client.GetObject(adobj.schema)
  for i in schema_obj.MandatoryProperties:
      value=getattr(adobj,i)
      if value_required and value==None: continue
      attr_dict[i]=value
  for i in schema_obj.OptionalProperties:
      value=getattr(adobj,i)
      if value_required and value==None: continue
      attr_dict[i]=value
  return attr_dict


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

Thanks!

-- 
--Jeff
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to