Closed wells01440 closed 7 years ago
Hi, Thanks for the info. Could you please tel me about your version of python, your version of ldap3 module and your version of Windows Server? I run Windows Server 2012 R2 with Python 3.4 and Python 3.5 and ldap3 1.4.0 and my ldap search results are not simple str ex:
{'sn': ['VERSCHOORE'], 'sAMAccountName': ['po.verschoore'], 'givenName': ['Pierre-Olivier'], 'mail': ['po.verschoore@xxx.com']}
Could you maybe try to replace line 309 by:
if isinstance(attributes[settings.LDAP_ATTRIBUTES_MAP[attr]], str):
attribute_value = attributes[settings.LDAP_ATTRIBUTES_MAP[attr]]
else:
attribute_value = attributes[settings.LDAP_ATTRIBUTES_MAP[attr]][0]
setattr(user, attr, attribute_value)
and tell me if it works for you?
Regards,
I'm getting the same issue
Hi, Could one or both of you tell me about his config? As I previously told, I don't experience the problem. Having a starting point to reproduce it would be nice.
Thanks.
I had the same problem. Obvious solution (removing index from last line) worked for me. Here someone did the same thing: https://github.com/wells01440/django_auth_ldap3_ad/commit/6e7efde696691b559acd81e3474b631c54113e33
There is pull request with your proposed solution (tested in my environment) - #10
Versions on client:
When creating new users, only the first character of the field gets saved in auth_users. For instance: In LDAP when givenName=Andrew, only 'A' gets saved.
The line of code causing it is 309 in auth.py:
setattr(user, attr, attributes[settings.LDAP_ATTRIBUTES_MAP[attr]][0])
From my settings.py
Changing line 309 to this fixes it for me
setattr(user, attr, attributes[settings.LDAP_ATTRIBUTES_MAP[attr]])
Thx, Andy