New Install - LDAP configured but django-auth-ldap unrecognized

392 views
Skip to first unread message

Thibault Chabert

unread,
Oct 6, 2020, 12:21:15 PM10/6/20
to NetBox

Hello everyone,

I'm strugling to activate LDAP to my new Unbuntu Netbox, following the guide https://netbox.readthedocs.io/en/stable/installation/6-ldap/

While it's working fine without LDAP, once I've changed the REMOTE_AUTH_BACKEND from RemoteUserBackend to LDAPBackend, I've been hit with the following error message on the web page :

##########################

There was a problem with your request. Please contact an administrator.

The complete exception is provided below:

<class 'django.core.exceptions.ImproperlyConfigured'>
LDAP authentication has been configured, but django-auth-ldap is not installed.
Python version: 3.6.9
NetBox version: 2.9.4

##########################

ldap is installed though :
netbox@netbox:~$ sudo pip3 list|grep ldap
[sudo] password for netbox:
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
django-auth-ldap (2.2.0)
python-ldap (3.3.1)

Any leads would be appreciated, despite searching there all afternoon, I did not manage to find a solution :(


Brian Candler

unread,
Oct 6, 2020, 12:28:18 PM10/6/20
to NetBox
You need to install it in the python virtualenv, not globally.

cd /opt/netbox
source venv/bin/activate
pip3 install ....

Better is to put it in "local_requirements.txt", and then it will automatically be installed on every upgrade (when the virtualenv is destroyed and recreated)

Brian Candler

unread,
Oct 6, 2020, 12:30:03 PM10/6/20
to NetBox
... as indeed is described in the installation instructions:

Thibault Chabert

unread,
Oct 6, 2020, 12:48:50 PM10/6/20
to NetBox
Hello Brian,

Thank you for the prompt answer !
Actually, I've installed it on the virtualenv and created the local_requirements.txt file :

(venv) netbox@netbox:/opt/netbox$ sudo -H pip3 install django-auth-ldap
Collecting django-auth-ldap
  Downloading https://files.pythonhosted.org/packages/e3/49/2297161849f1133ddafd8f81e6e48323db100fda7b4cd211cf7a9a453d2f/django_auth_ldap-2.2.0-py3-none-any.whl
Requirement already satisfied: python-ldap>=3.1 in /usr/local/lib/python3.6/dist-packages (from django-auth-ldap)
Requirement already satisfied: Django>=1.11 in /usr/local/lib/python3.6/dist-packages (from django-auth-ldap)
Requirement already satisfied: pyasn1-modules>=0.1.5 in /usr/lib/python3/dist-packages (from python-ldap>=3.1->django-auth-ldap)
Requirement already satisfied: pyasn1>=0.3.7 in /usr/lib/python3/dist-packages (from python-ldap>=3.1->django-auth-ldap)
Requirement already satisfied: asgiref~=3.2.10 in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-auth-ldap)
Requirement already satisfied: pytz in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-auth-ldap)
Requirement already satisfied: sqlparse>=0.2.2 in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-auth-ldap)
Installing collected packages: django-auth-ldap
Successfully installed django-auth-ldap-2.2.0

netbox@netbox:/opt/netbox$ cat local_requirements.txt
django-auth-ldap

netbox@netbox:/opt/netbox$ cat /etc/systemd/system/netbox.service
[Unit]
Description=NetBox WSGI Service
Documentation=https://netbox.readthedocs.io/en/stable/
After=network-online.target
Wants=network-online.target

[Service]
Type=simple

User=netbox
Group=netbox
PIDFile=/var/tmp/netbox.pid
WorkingDirectory=/opt/netbox

ExecStart=/opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --config /opt/netbox/gunicorn.py netbox.wsgi

Restart=on-failure
RestartSec=30
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Thibault Chabert

unread,
Oct 7, 2020, 9:05:29 AM10/7/20
to NetBox
Hello,

Problem was solved by running the upgrade script once more, without configuration change.
Reply all
Reply to author
Forward
0 new messages