So I am trying to modify a user in my active directory. As of now I can log in as an AD-user but when I try to edit my profile, it does not implement in the AD.
I use django-auth-ldap
for AD backend.
I made a connection with a user that has reading and writing permissions.
AUTH_LDAP_SERVER_URI = "ldap://192.168.1.12"
AUTH_LDAP_BIND_DN = "user"
AUTH_LDAP_BIND_PASSWORD = "password"
AUTH_LDAP_CONNECTION_OPTIONS = {
ldap.OPT_DEBUG_LEVEL: 1,
ldap.OPT_REFERRALS: 0
}
AUTH_LDAP_USER_SEARCH = LDAPSearch("DC=sb,DC=ch", ldap.SCOPE_SUBTREE, "(sAMAccountName=%(user)s)")
# Set up the basic group parameters.
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("DC=sb,DC=ch", ldap.SCOPE_SUBTREE, "(objectClass=group)")
AUTH_LDAP_GROUP_TYPE = NestedActiveDirectoryGroupType()
# What to do once the user is authenticated
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail"
}
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
"is_active": "CN=ipa-users,cn=users,DC=sb,DC=ch",
"is_staff": "CN=ipa-users,cn=users,DC=sb,DC=ch",
"is_superuser": "CN=ipa-users,cn=users,DC=sb,DC=ch"
}
# This is the default, but be explicit.
AUTH_LDAP_ALWAYS_UPDATE_USER = True
# Use LDAP group membership to calculate group permissions.
AUTH_LDAP_FIND_GROUP_PERMS = True
# Cache settings
AUTH_LDAP_CACHE_GROUPS = True
AUTH_LDAP_GROUP_CACHE_TIMEOUT = 3600
AUTHENTICATION_BACKENDS = (
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
)
So what and where do I have to set or get anything?
This is my edit_profile.html:
<form method="post">
{% csrf_token %}
<label for="first_name">Vorname </label>
<input style="margin-bottom: 1em;" id="first_name" class="form-control" type="text" name="first_name" value="{{ user.first_name }}"><br>
<label for="last_name">Nachname </label>
<input style=" margin-bottom: 1em;" id="last_name" class="form-control" type="text" name="last_name" value="{{ user.last_name }}"><br>
<label for="email">E-Mail </label>
<input style="margin-bottom: 1em;" id="email" class="form-control" type="email" required=True unique=True name="email" value="{{ user.email }}"><br>
<button class="btn btn-success btn-sm" type="submit">Bestätigen</button>