Netbox-2.9.8 - Python 3.6.8 - LDAP Config - ldap_config.py does not exist

701 views
Skip to first unread message

Olivier Calzi

unread,
Nov 9, 2020, 3:59:18 AM11/9/20
to NetBox

Dears,

I’m writting to you because i’m facing a dumb issue, i can’t get the LDAP authentication working as i’m getting this error message :

I’ve tried several thing like:
- have my file copied into each layer of the netbox app folders
- had a look at authentication.py
- checked the owner etc based on few docs available regarding LDAP + Netbox
- setup the logging handler within the configuration.py (content blank)

My ldap_config.py lies close to the configuration.py as asked by the docs, it’s not even about how my ldap_config is configured as i got this from authentication.py.
-rwxrwxr-x 1 netbox netbox 3.0K Nov 9 09:31 ldap_config.py
Could anyone show me the light ?

Thanks,
Olivier Calzi

Brian Candler

unread,
Nov 9, 2020, 4:59:29 AM11/9/20
to NetBox
Please use text copy-paste for error messages, not images.  Your screenshot shows as a blank white box (in Google Groups web interface anyway).


it’s not even about how my ldap_config is configured as i got this from authentication.py.
-rwxrwxr-x 1 netbox netbox 3.0K Nov 9 09:31 ldap_config.py

What do you mean by "got this from authentication.py"? Your ldap_config.py should not be a copy of authentication.py, but should contain AUTH_LDAP_xxx settings, as documented at https://netbox.readthedocs.io/en/stable/installation/6-ldap/#configuration

Brian Candler

unread,
Nov 9, 2020, 5:13:35 AM11/9/20
to NetBox
Also, I'm not sure exactly what circumstances can lead Python to raise an ImportError (or its child, ModuleNotFoundError), and it's possible that error message "ldap_config.py does not exist" could be misleading.

Please can you find this code in authentication.py

        try:
            from netbox import ldap_config
        except ImportError:
            raise ImproperlyConfigured(
                "ldap_config.py does not exist"
            )

and change it to:

        try:
            from netbox import ldap_config
        except ImportError as err:
            raise ImproperlyConfigured(
                "ldap_config.py does not exist or other problem: %s" % err
            )

What does the error say now?

Olivier Calzi

unread,
Nov 9, 2020, 5:22:32 AM11/9/20
to NetBox
Hello Brian,

I just saw that my screenshot wasn’t displayed in the right way.
Thanks for your hints, i have a better lead now as i’ve got « ldap_config.py does not exist or other problem: cannot import name 'NestedGoupOfNamesType'» from the modification you advised.

Will let you know if i manage to fix my situation with this log :).

Regards,
Olivier Calzi

Brian Candler

unread,
Nov 9, 2020, 5:31:16 AM11/9/20
to NetBox
On Monday, 9 November 2020 10:22:32 UTC, Olivier Calzi wrote:
cannot import name 'NestedGoupOfNamesType'» from the modification you advised.


Probably because you wrote "Goup" rather than "Group" :-)

Olivier Calzi

unread,
Nov 9, 2020, 5:45:06 AM11/9/20
to NetBox
Brian,

Not really, it was about import the NestedGroupOfNamesType class, i had to let GroupOfNamesType also as :
```
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType, NestedGroupOfNamesType

# This search ought to return all groups to which the user belongs. django_auth_ldap uses this to determine group
# hierarchy.
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("YYYYYYYYYXXXXXXXl", ldap.SCOPE_SUBTREE, "(objectClass=group)")
AUTH_LDAP_GROUP_TYPE = NestedGroupOfNamesType()

```

At the end, it solved my issue. Thanks a lot.
Have a good week guys !

Regards,
Olivier Calzi

Brian Candler

unread,
Nov 9, 2020, 5:53:13 AM11/9/20
to NetBox
Excellent.  I've submitted a FR for better error report in that situation:

Reply all
Reply to author
Forward
0 new messages