Non capisco come usare LDAPBackend in django, tutto quello che voglio fare è autenticare un utente contro LDAP. Ho provato la seguente:Autenticazione utente Django: django_auth_ldap.backend.LDAPBackend
from django_auth_ldap.backend import LDAPBackend
auth = LDAPBackend()
user = auth.authenticate(username='my_uid',password='pwd')
A questo punto è utente Nessuno e guardando tcpdump non riesco a vedere alcun tentativo di connessione al server LDAP.
settings.pyAUTH_LDAP_SERVER_URI = 'ldap.example.com'
AUTH_LDAP_USER_DN_TEMPLATE = 'uid=%(user)s,ou=People,dc=example,dc=com'
AUTH_LDAP_BIND_AS_AUTHENTICATING_USER = True
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_auth_ldap.backend.LDAPBackend',
)
il Django doc ufficiale non fornisce alcun frammento su come utilizzare questo backend in una vista.
Mille grazie per il vostro aiuto!
Questo è vero. Il documento ufficiale di Django è estremamente limitato. – shailenTJ