furlongm/patchman

LDAP \ AD authentication not working

jaydeepch15 opened this issue · 2 comments

Hi,

I have configured patchman and its working in my production environment.
Thanks to @furlongm for timely help.

To take it in next step I tried to integrate LDAP /AD for login method.

I tried below snippet in local_settings.py


AUTH_LDAP_BIND_DN = "CN=myuser,OU=dnadm,OU=ServiceAccounts,OU=dnadm-Accounts,DC=myorg,DC=net"
AUTH_LDAP_BIND_PASSWORD = "myuserpasswd"


import ldap
from django_auth_ldap.config import LDAPSearch
AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=dnadm-Accounts,DC=myorg,DC=net",
                                   ldap.SCOPE_SUBTREE,
                                   "(sAMAccountName=%(user)s)")



AUTH_LDAP_USER_ATTR_MAP = {
    "username": "sAMAccountName",
    "first_name": "givenName",
    "last_name": "sn",
    "email":"mail"
}


AUTHENTICATION_BACKENDS = (
    "django_auth_ldap.backend.LDAPBackend",
    "django.contrib.auth.backends.ModelBackend",
)

AUTH_LDAP_CONNECTION_OPTIONS = {
    ldap.OPT_REFERRALS: 0
}

Then reboot the patchman server.After reboot when try to Login via LDAP/AD user its not working.
Not sure where can I find logs for it, so couldnt share log destails for this failure.

What am I doing wrong for AD code snippet?

Hi @jaydeepjc ,

You can use the following reference to find the right ldap configuration (https://django-auth-ldap.readthedocs.io/en/latest/example.html).

To retrieve LDAP log, you can add the following code snippet in local_settings.py:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "handlers": {"console": {"class": "logging.StreamHandler"}},
    "loggers": {"django_auth_ldap": {"level": "DEBUG", "handlers": ["console"]}},
}

You should see the LDAP logs in output console when you launch patchman application.

Closing as this is an auth issue, see upstream docs for settings that up.