I'm using win32com to query AD for the adsPath as below.  It's come to my
attention that a user with unicode is apparently breaking this.

user = 'mrunicode'
dnc =
win32com.adsi.ADsGetObject('LDAP://rootDSE').Get('DefaultNamingContext')
ado = win32com.client.Dispatch('ADODB.Connection')
ado.Open('Provider=ADsDSOObject')
lfilter = '(&(sAMAccountName=%s)(objectCategory=User))' % user
search = '<LDAP://%s>;%s;adsPath;subtree' % (dnc, lfilter)
obj_record = ado.Execute(search)[0]
print obj_record.Fields('adsPath'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python_26\files\lib\site-packages\win32com\client\dynamic.py",
line 201, in __str__
    return str(self.__call__())
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in
position 11: ordinal not in range(128)

Is there a workaround for this?
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to