【发布时间】:2016-05-18 11:59:42
【问题描述】:
我一直在尝试使用在这里找到的 sn-p https://djangosnippets.org/snippets/2899/ 来拥有一个 ldap 后端,但是当我现在登录到我的管理页面时,我得到了错误
TypeError at /admin/login/
'NoneType' object has no attribute '__getitem__'
Request Method: POST
Request URL: http://it.intranet.com/admin/login/?next=/admin/
Django Version: 1.9.6
Exception Type: TypeError
Exception Value:
'NoneType' object has no attribute '__getitem__'
Exception Location: /var/www/infternal/infternal/backend.py in get_or_create_user, line 69
Python Executable: /usr/bin/python
Python Version: 2.7.5
Python Path:
['/var/www/infternal',
'/usr/lib64/python27.zip',
'/usr/lib64/python2.7',
'/usr/lib64/python2.7/plat-linux2',
'/usr/lib64/python2.7/lib-tk',
'/usr/lib64/python2.7/lib-old',
'/usr/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7/site-packages',
'/usr/lib64/python2.7/site-packages/gtk-2.0',
'/usr/lib/python2.7/site-packages']
Server time: Wed, 18 May 2016 11:54:09 +0000
我想这是因为我没有成功连接到 ldap 服务器?
我该如何测试?
后端代码完全从 sn-p 复制而来。 我的 settings.py 如下
我唯一不确定的是 AD_CERT_FILE 字段,我不知道它在哪里,也不知道该放什么,但由于我没有使用 ssl,所以我认为它不需要?
# active directory authentication module
AD_DNS_NAME = 'example.domain.com' # FQDN of your DC (using just the Domain Name to utilize all DC's)
# If using non-SSL use these
AD_LDAP_PORT=389
AD_LDAP_URL='ldap://%s:%s' % (AD_DNS_NAME,AD_LDAP_PORT)
# If using SSL use these:
#AD_LDAP_PORT=636
#AD_LDAP_URL='ldaps://%s:%s' % (AD_DNS_NAME,AD_LDAP_PORT)
AD_SEARCH_DN = 'DC=example,DC=domain,DC=com'
AD_NT4_DOMAIN = 'example.domain.COM'
AD_SEARCH_FIELDS = ['mail','givenName','sn','sAMAccountName','memberOf']
AD_MEMBERSHIP_ADMIN = ['ITService_App_Admin'] # this ad group gets superuser status in django
# only members of this group can access
AD_MEMBERSHIP_REQ = AD_MEMBERSHIP_ADMIN + ['GS_ITsupport',
'GS_ITDevelopment',]
AD_CERT_FILE = '/certs/certfile' # this is the certificate of the Certificate Authority issuing your DCs certificate
AD_DEBUG=True #Set to false for prod, Slows things down ALOT
AD_DEBUG_FILE='/tmp/ldap.debug'
AUTHENTICATION_BACKENDS = (
'infternal.backend.ActiveDirectoryAuthenticationBackend',
'django.contrib.auth.backends.ModelBackend', #Comment out to prevent authentication from DB
)
【问题讨论】:
-
在 Google Hangouts 上给我打电话,也许我可以帮你弄清楚。
标签: python django active-directory