0

I am using Django-auth-ldap to authenticate ldap users into my app. I need to change the ldap settings like SERVER_URI, bind_dn, password etc from my app while Django server is running.

Can I override settings method from django-auth-ldap/django_auth_ldap/backend.py so I can pass the changed settings to django-auth-ldap without having to restart the server?

I tried class CustomLDAPBackend(LDAPBackend): def authenticate_ldap_user(self, username, password): """ Overrides LDAPBackend.authenticate to save user password in django """ user = LDAPBackend.authenticate_ldap_user(self, username, password) ....

def settings(self): # Gettings settings from my app lsettings = LDAPManager().get_settings() if lsettings: self.default_settings = lsettings LDAPBackend.settings()

My logic is initially at starting of the server, I want to just go with the default_settings from ldap config.py After I get the changed values using lsettings = LDAPManager().get_settings() , I want to pass them to django-auth-ldap backend, so next time I try to authenticate an ldap user, the app uses the modified settings without having to restart the django server.

But this code is not working. I get error as
"django_auth_ldap 'function' object has no attribute 'USER_DN_TEMPLATE' while authenticating ldapuser"

0 Answers0