django-ldap auth和django 1.6对user_profile的弃用警告

时间:2014-07-22 09:13:46

标签: python django openldap django-auth-ldap

在运行python 2.7的Linux上使用django-auth-ldap(1.2.0)和django 1.6时,我收到警告:

The use of AUTH_PROFILE_MODULE to define user profiles has been deprecated.
  profile = self._user.get_profile()

我的settings.py包含LDAP设置:

import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType

# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.
AUTHENTICATION_BACKENDS = (
    'django_auth_ldap.backend.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
)

AUTH_LDAP_SERVER_URI = "ldap://127.0.0.1"
AUTH_LDAP_BIND_DN = "cn=ram Krishna,ou=users,dc=test,dc=com"
AUTH_LDAP_BIND_PASSWORD = "ram"
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=test,dc=com",
                                   ldap.SCOPE_SUBTREE, "(uid=%(user)s)")

此py文件中没有其他LDAP设置

我的带有ldapsearch -x的slapd条目显示:

# ram Krishna, users, test.com
dn: cn=ram Krishna,ou=users,dc=test,dc=com
cn: ram Krishna
mail: ram@y.com
givenName: ram
sn: Krishna
objectClass: inetOrgPerson
objectClass: top
uid: ram

为什么我无法进行身份验证?

1 个答案:

答案 0 :(得分:0)

我收到同样的警告,但我的ldap工作正常。

我只看到您的LDAP设置和我的

之间存在2个差异
1. AUTH_LDAP_BIND_DN = "???@test.com"
2. AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=test,dc=com", ldap.SCOPE_SUBTREE, u"(sAMAccountName=%(user)s)")