django-python3-ldap: Problem with ldap_sync_users command (need ldap3 v2.2.3 module)

Hello, Thanks for your clear documentation 😃 I try to make working your module for the first time but I have some issue.

My LDAP server is particular and need the last stable version (2.2.3) of ldap3 python module. You can see the issue corrected 2 days ago here : https://github.com/cannatag/ldap3/issues/334

When I try to import ldap users in django with your module, it’s not working.

You can see my try here :

gduale:~:$ . ./py361-test/bin/activate
(py361-test) gduale:~:$ pip install django-python3-ldap
Collecting django-python3-ldap
  Using cached django-python3-ldap-0.9.14.tar.gz
Collecting django>=1.8 (from django-python3-ldap)
  Using cached Django-1.11-py2.py3-none-any.whl
Collecting ldap3==2.2.0 (from django-python3-ldap)
  Using cached ldap3-2.2.0-py2.py3-none-any.whl
Collecting pytz (from django>=1.8->django-python3-ldap)
  Using cached pytz-2017.2-py2.py3-none-any.whl
Collecting pyasn1>=0.1.8 (from ldap3==2.2.0->django-python3-ldap)
  Using cached pyasn1-0.2.3-py2.py3-none-any.whl
Installing collected packages: pytz, django, pyasn1, ldap3, django-python3-ldap
  Running setup.py install for django-python3-ldap ... done
Successfully installed django-1.11 django-python3-ldap-0.9.14 ldap3-2.2.0 pyasn1-0.2.3 pytz-2017.2

Then I know that with ldap3 version 2.2.0 it will not work (I already try), so I install the latest version :

(py361-test) gduale:~:$ pip install --upgrade ldap3
Collecting ldap3
  Using cached ldap3-2.2.3-py2.py3-none-any.whl
Requirement already up-to-date: pyasn1>=0.1.8 in ./py361-test/lib/python3.6/site-packages (from ldap3)
Installing collected packages: ldap3
  Found existing installation: ldap3 2.2.0
    Uninstalling ldap3-2.2.0:
      Successfully uninstalled ldap3-2.2.0
Successfully installed ldap3-2.2.3

Then I try to sync the users, but it fails :

(py361-test) gduale:~/django-projects/test-c2i/c2i:$ python manage.py ldap_sync_users
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/gduale/make_python/python-3.6.1/lib/python3.6/contextlib.py", line 53, in inner
    return func(*args, **kwds)
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django_python3_ldap/management/commands/ldap_sync_users.py", line 21, in handle
    for user in connection.iter_users():
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django_python3_ldap/ldap.py", line 90, in <genexpr>
    if entry["type"] == "searchResEntry"
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django_python3_ldap/ldap.py", line 66, in _get_or_create_user
    **user_lookup
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django/db/models/query.py", line 475, in update_or_create
    lookup, params = self._extract_model_params(defaults, **kwargs)
  File "/home/gduale/py361-test/lib/python3.6/site-packages/django/db/models/query.py", line 531, in _extract_model_params
    "', '".join(sorted(invalid_params)),
django.core.exceptions.FieldError: Invalid field name(s) for model User: 'd', 'i', 'u'.

Do you know if is it possible to make working your module with the latest stable version of ldap3 please ? Thank you, Best regards.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Excellent! LDAP is needlessly hard!

On Wed, 3 May 2017 at 10:53 tazou notifications@github.com wrote:

Hi, Sorry my fault… I change this parameter with : LDAP_AUTH_USER_LOOKUP_FIELDS = (ā€œusernameā€,)

And now the synchronization is working !

Thank a lot again for all your help !

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/etianen/django-python3-ldap/issues/78#issuecomment-298868106, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCD4O-gYzXWMiN1FFpAQtFAGjx3u1ks5r2E6UgaJpZM4NOJyO .