How can i connect my LDAP authentication for Django?
I am currently implementing LDAP authentication to Django. I created the Windows Server VM, and pinged it on my main pc and viceversa, also used
ldapsearch -x -H ldap://192.168.0.136 -D "Administrator@statuspage.com" -W -b "DC=statuspage,DC=com"
and everything works as it should, however when I try to login on django admin page with the code provided on the ldap documentation it doesn't work, neither on python manage.py shell nor on the localhost/admin page.
I've been using STATUSPAGE\Administrator, Administrator@statuspage.com and Administrator alone for username, none works, here is the code I used:
import ldap
from django_auth_ldap.config import LDAPSearch
import logging
logger = logging.getLogger('django_auth_ldap')
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
AUTH_LDAP_SERVER_URI = "ldap://192.168.0.136"
AUTH_LDAP_BIND_DN = "dc=statuspage,dc=com"
AUTH_LDAP_BIND_PASSWORD = "my_password" #in the code I actually put the server password
AUTH_LDAP_USER_SEARCH = LDAPSearch(
"ou=Users,dc=statuspage,dc=com",
ldap.SCOPE_SUBTREE,
"(uid=%(user)s)"
)
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
}
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
Everytime I log with the user on shell I get this error:
Caught LDAPError while authenticating STATUSPAGE\jdoe: INVALID_CREDENTIALS({'msgtype': 97, 'msgid': 1, 'result': 49, 'desc': 'Invalid credentials', 'ctrls': [], 'info': '80090308: LdapErr: DSID-0C090439, comment: AcceptSecurityContext error, data 57, v4563'})