Pro 7.1.3 ldapsync not working

Hi, I upgraded my test server from Pro 7.0.10 to 7.1.3. Now I tried to use the ldap sync feature, but I’m getting the following error:

[seafile@server seafile-server-latest]$ pro/pro.py ldapsync --test
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/seafile/seafile-pro-server-7.1.3/pro/python/seafevents/ldap_syncer/run_ldap_sync.py", line 7, in <module>
    from ldap import SCOPE_SUBTREE
ModuleNotFoundError: No module named 'ldap'

LDAP authentication works like before. I’m on Scientific Linux 7.7.

OK, you answered this here: Seafile Server Professional Edition 7.1: Preparing the foundation for the next development stage
So, for using ldap sync I really have to switch to CentOS 8, I think.

I finally got ldap sync to work. I had to install python3-devel rpm and then I had to call “pip3 install python3-ldap” and also “pip3 install python-ldap”

# yum install python3 python3-setuptools python3-pip python3-devel -y
# pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools django-pylibmc django-simple-captcha python3-ldap python-ldap
1 Like

Hi,

I had the same issue on Debian 10 / Python 3.7

The manual is limited to python3-ldap
https://download.seafile.com/published/seafile-manual/upgrade/upgrade_notes_for_7.1.x.md

pip3 install python3-ldap

But with that you get this error while syncing

./pro.py ldapsync --test
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/cc/seafile/seafile-pro-server-7.1.3/pro/python/seafevents/ldap_syncer/run_ldap_sync.py", line 7, in <module>
    from ldap import SCOPE_SUBTREE
ModuleNotFoundError: No module named 'ldap'

In you try to install python-ldap, dependencies are not satisfied

    sudo pip3 install python-ldap
Collecting python-ldap
  Downloading https://files.pythonhosted.org/packages/ea/93/596f875e003c770447f4b99267820a0c769dd2dc3ae3ed19afe460fcbad0/python-ldap-3.2.0.tar.gz (367kB)
    100% |████████████████████████████████| 368kB 2.9MB/s
Requirement already satisfied: pyasn1>=0.3.7 in /usr/local/lib/python3.7/dist-packages (from python-ldap) (0.4.8)
Collecting pyasn1_modules>=0.1.5 (from python-ldap)
  Downloading https://files.pythonhosted.org/packages/95/de/214830a981892a3e286c3794f41ae67a4495df1108c3da8a9f62159b9a9d/pyasn1_modules-0.2.8-py2.py3-none-any.whl (155kB)
    100% |████████████████████████████████| 163kB 5.8MB/s
Building wheels for collected packages: python-ldap
  Running setup.py bdist_wheel for python-ldap ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-f4uu4h6n/python-ldap/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-47ohktr0 --python-tag cp37:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  copying Lib/ldapurl.py -> build/lib.linux-x86_64-3.7
  copying Lib/ldif.py -> build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/logger.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/pkginfo.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/functions.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/modlist.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/resiter.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/filter.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/cidict.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/sasl.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/syncrepl.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/__init__.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/asyncsearch.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/async.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/ldapobject.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/compat.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/dn.py -> build/lib.linux-x86_64-3.7/ldap
  copying Lib/ldap/constants.py -> build/lib.linux-x86_64-3.7/ldap
  creating build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/vlv.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/readentry.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/ppolicy.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/sessiontrack.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/libldap.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/pagedresults.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/psearch.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/simple.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/__init__.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/sss.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/deref.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/pwdpolicy.py -> build/lib.linux-x86_64-3.7/ldap/controls
  copying Lib/ldap/controls/openldap.py -> build/lib.linux-x86_64-3.7/ldap/controls
  creating build/lib.linux-x86_64-3.7/ldap/extop
  copying Lib/ldap/extop/dds.py -> build/lib.linux-x86_64-3.7/ldap/extop
  copying Lib/ldap/extop/__init__.py -> build/lib.linux-x86_64-3.7/ldap/extop
  creating build/lib.linux-x86_64-3.7/ldap/schema
  copying Lib/ldap/schema/subentry.py -> build/lib.linux-x86_64-3.7/ldap/schema
  copying Lib/ldap/schema/tokenizer.py -> build/lib.linux-x86_64-3.7/ldap/schema
  copying Lib/ldap/schema/models.py -> build/lib.linux-x86_64-3.7/ldap/schema
  copying Lib/ldap/schema/__init__.py -> build/lib.linux-x86_64-3.7/ldap/schema
  creating build/lib.linux-x86_64-3.7/slapdtest
  copying Lib/slapdtest/_slapdtest.py -> build/lib.linux-x86_64-3.7/slapdtest
  copying Lib/slapdtest/__init__.py -> build/lib.linux-x86_64-3.7/slapdtest
  running egg_info
  writing Lib/python_ldap.egg-info/PKG-INFO
  writing dependency_links to Lib/python_ldap.egg-info/dependency_links.txt
  writing requirements to Lib/python_ldap.egg-info/requires.txt
  writing top-level names to Lib/python_ldap.egg-info/top_level.txt
  reading manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  no previously-included directories found matching 'Doc/.build'
  writing manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
  creating build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/README -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/ca.conf -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/ca.pem -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/client.conf -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/client.key -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/client.pem -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/gencerts.sh -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/gennssdb.sh -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/server.conf -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/server.key -> build/lib.linux-x86_64-3.7/slapdtest/certs
  copying Lib/slapdtest/certs/server.pem -> build/lib.linux-x86_64-3.7/slapdtest/certs
  running build_ext
  building '_ldap' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/Modules
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=3.2.0 -DLDAPMODULE_AUTHOR=python-ldap project -DLDAPMODULE_LICENSE=Python style -IModules -I/usr/include/python3.7m -c Modules/LDAPObject.c -o build/temp.linux-x86_64-3.7/Modules/LDAPObject.o
  In file included from Modules/LDAPObject.c:8:
  Modules/constants.h:7:10: fatal error: lber.h: Aucun fichier ou dossier de ce type
   #include "lber.h"
            ^~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for python-ldap
  Running setup.py clean for python-ldap
Failed to build python-ldap
Installing collected packages: pyasn1-modules, python-ldap
  Running setup.py install for python-ldap ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-f4uu4h6n/python-ldap/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-hez3oao0/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    copying Lib/ldapurl.py -> build/lib.linux-x86_64-3.7
    copying Lib/ldif.py -> build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/logger.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/pkginfo.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/functions.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/modlist.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/resiter.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/filter.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/cidict.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/sasl.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/syncrepl.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/__init__.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/asyncsearch.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/async.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/ldapobject.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/compat.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/dn.py -> build/lib.linux-x86_64-3.7/ldap
    copying Lib/ldap/constants.py -> build/lib.linux-x86_64-3.7/ldap
    creating build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/vlv.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/readentry.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/ppolicy.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/sessiontrack.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/libldap.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/pagedresults.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/psearch.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/simple.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/__init__.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/sss.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/deref.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/pwdpolicy.py -> build/lib.linux-x86_64-3.7/ldap/controls
    copying Lib/ldap/controls/openldap.py -> build/lib.linux-x86_64-3.7/ldap/controls
    creating build/lib.linux-x86_64-3.7/ldap/extop
    copying Lib/ldap/extop/dds.py -> build/lib.linux-x86_64-3.7/ldap/extop
    copying Lib/ldap/extop/__init__.py -> build/lib.linux-x86_64-3.7/ldap/extop
    creating build/lib.linux-x86_64-3.7/ldap/schema
    copying Lib/ldap/schema/subentry.py -> build/lib.linux-x86_64-3.7/ldap/schema
    copying Lib/ldap/schema/tokenizer.py -> build/lib.linux-x86_64-3.7/ldap/schema
    copying Lib/ldap/schema/models.py -> build/lib.linux-x86_64-3.7/ldap/schema
    copying Lib/ldap/schema/__init__.py -> build/lib.linux-x86_64-3.7/ldap/schema
    creating build/lib.linux-x86_64-3.7/slapdtest
    copying Lib/slapdtest/_slapdtest.py -> build/lib.linux-x86_64-3.7/slapdtest
    copying Lib/slapdtest/__init__.py -> build/lib.linux-x86_64-3.7/slapdtest
    running egg_info
    writing Lib/python_ldap.egg-info/PKG-INFO
    writing dependency_links to Lib/python_ldap.egg-info/dependency_links.txt
    writing requirements to Lib/python_ldap.egg-info/requires.txt
    writing top-level names to Lib/python_ldap.egg-info/top_level.txt
    reading manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'Doc/.build'
    writing manifest file 'Lib/python_ldap.egg-info/SOURCES.txt'
    creating build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/README -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/ca.conf -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/ca.pem -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/client.conf -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/client.key -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/client.pem -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/gencerts.sh -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/gennssdb.sh -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/server.conf -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/server.key -> build/lib.linux-x86_64-3.7/slapdtest/certs
    copying Lib/slapdtest/certs/server.pem -> build/lib.linux-x86_64-3.7/slapdtest/certs
    running build_ext
    building '_ldap' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/Modules
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=3.2.0 -DLDAPMODULE_AUTHOR=python-ldap project -DLDAPMODULE_LICENSE=Python style -IModules -I/usr/include/python3.7m -c Modules/LDAPObject.c -o build/temp.linux-x86_64-3.7/Modules/LDAPObject.o
    In file included from Modules/LDAPObject.c:8:
    Modules/constants.h:7:10: fatal error: lber.h: Aucun fichier ou dossier de ce type
     #include "lber.h"
              ^~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-f4uu4h6n/python-ldap/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-hez3oao0/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in 

Looking at the the module doc, you need some dependencies to compile python-ldap

https://www.python-ldap.org/en/python-ldap-3.2.0/installing.html#build-prerequisites

apt-get install build-essential python3-dev python2.7-dev \
    libldap2-dev libsasl2-dev slapd ldap-utils python-tox \
    lcov valgrind

For my own, i only neeeded this

apt-get install build-essential	libldap2-dev

then

python -m pip install python-ldap
./pro.py ldapsync --test

Ldap sync works now.

@daniel.pan, is python-ldap mandatory? If yes, could you update thne manual ?