Maybe, anybody know... I need add LDAP user inside admin panel.
My autentithication LDAP in Django works, but I have to add users very strange. First they log in and they are not allowed. Then I go to admin panel and see user is added, but without the Staff status flag. I activate the flag. The user can log in with his LDAP account.
Question: Is it possible to first add an LDAP user in the admin panel itself and activate everything that is needed so that the user does not have to log in twice?
AUTH_LDAP_SERVER_URI = "ldap://X.X.X.X:389"
AUTH_LDAP_BIND_DN = "CN=CN,OU=OU,DC=domain,DC=local"
AUTH_LDAP_BIND_PASSWORD = "pass"
AUTH_LDAP_USER_SEARCH = LDAPSearch("OU=OU,DC=domain,DC=local",
ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)"
)
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("ou=Users,dc=domain,dc=local",
ldap.SCOPE_SUBTREE, "(objectClass=group)"
)
AUTH_LDAP_GROUP_TYPE = GroupOfNamesType()
AUTH_LDAP_CONNECTION_OPTIONS = {
ldap.OPT_DEBUG_LEVEL: 0,
ldap.OPT_REFERRALS: 0,
}
AUTHENTICATION_BACKENDS = [
"django_auth_ldap.backend.LDAPBackend",
"django.contrib.auth.backends.ModelBackend",
]
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
AUTH_LDAP_ALWAYS_UPDATE_USER = True
AUTH_LDAP_FIND_GROUP_PERMS = True
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600