Django 응용 프로그램이 python-ldap 라이브러리 (ldap_groups django 응용 프로그램)를 사용하고 Windows 2003 가상 시스템 도메인의 Active Directory에 대해 사용자를 추가해야합니다. 우분투 가상 머신에서 실행되는 응용 프로그램은 Windows 도메인의 구성원이 아닙니다. 여기 ldap가 수행 할 오류 발생
코드입니다 :settings.py
DNS_NAME='IP_ADRESS'
LDAP_PORT=389
LDAP_URL='ldap://%s:%s' % (DNS_NAME,LDAP_PORT)
BIND_USER='cn=administrateur,cn=users,dc=my,dc=domain,dc=fr'
BIND_PASSWORD="AdminPassword"
SEARCH_DN='cn=users,dc=my,dc=domain,dc=fr'
NT4_DOMAIN='E2C'
SEARCH_FIELDS= ['mail','givenName','sn','sAMAccountName','memberOf']
MEMBERSHIP_REQ=['Group_Required','Alternative_Group']
AUTHENTICATION_BACKENDS = (
'ldap_groups.accounts.backends.ActiveDirectoryGroupMembershipSSLBackend',
'django.contrib.auth.backends.ModelBackend',
)
DEBUG=True
DEBUG_FILE='/$HOME/ldap.debug'
내 코드를 추적 할 때, "사용자의 호출을 추가하는 동안 문제가있는 것 같다
import ldap
import ldap.modlist as modlist
username, email, password = kwargs['username'], kwargs['email'], kwargs['password1']
ldap.set_option(ldap.OPT_REFERRALS, 0)
# Open a connection
l = ldap.initialize(settings.LDAP_URL)
# Bind/authenticate with a user with apropriate rights to add objects
l.simple_bind_s(settings.BIND_USER,settings.BIND_PASSWORD)
# The dn of our new entry/object
dn="cn=%s,%s" % (username,settings.SEARCH_DN)
# A dict to help build the "body" of the object
attrs = {}
attrs['objectclass'] = ['top','organizationalRole','simpleSecurityObject']
attrs['cn'] = username.encode('utf-16')
attrs['userPassword'] = password.encode('utf-16')
attrs['description'] = 'User object for replication using slurpd'
# Convert our dict to nice syntax for the add-function using modlist-module
ldif = modlist.addModlist(attrs)
# Do the actual synchronous add-operation to the ldapserver
l.add_s(dn,ldif)
# Its nice to the server to disconnect and free resources when done
l.unbind_s()
backends.py l.add_s ". 내가 잘못 자격 증명을 사용하는 경우 서버가 잘못된 증명서를 반환, 그래서 내가 위에서 사용하고 자격 증명이 LDAP 디렉토리에 바인딩 할 올바른 생각
UNWILLING_TO_PERFORM at /accounts/register/
{'info': '00002077: SvcErr: DSID-031907B4, problem 5003 (WILL_NOT_PERFORM), data 0\n', 'desc': 'Server is unwilling to perform'}
:
그러나 그것은 다음 오류를 반환합니다.
아마도 내 우분투 도메인의 구성원이어야합니까 또는 내 코드에서 뭔가 잘못 되었습니까?