使用Django 1.4和django-auth-ldap 1.1,我正在尝试配置我的Web应用程序以针对LDAP服务对用户进行身份验证。在登录表单中提供正确的登录凭据时,我收到此错误: -
/ login /
中的TypeError需要一个整数
请求方法:POST
请求网址:http://mydomain.com:8000/login/
Django版本:1.4
异常类型:TypeError
例外值:
需要一个整数
异常位置:_ldap_function_call,第57行中的/usr/lib/python2.6/dist-packages/ldap/functions.py Python可执行文件:/ usr / bin / python
Python版本:2.6.5
.... Python路径信息
为什么会发生这种错误?
以下是粘贴的跟踪信息: -
Environment:
Request Method: POST
Request URL: http://localhost:8000/login/
Django Version: 1.4
Python Version: 2.6.5
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'myapp')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/debug.py" in wrapper
69. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/views.py" in login
36. if form.is_valid():
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in is_valid
124. return self.is_bound and not bool(self.errors)
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in _get_errors
115. self.full_clean()
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in full_clean
271. self._clean_form()
File "/usr/local/lib/python2.6/dist-packages/django/forms/forms.py" in _clean_form
299. self.cleaned_data = self.clean()
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/forms.py" in clean
167. password=password)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/__init__.py" in authenticate
43. for backend in get_backends():
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/__init__.py" in get_backends
34. backends.append(load_backend(backend_path))
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/__init__.py" in load_backend
28. return cls()
File "/usr/local/lib/python2.6/dist-packages/django_auth_ldap-1.1.1-py2.6.egg/django_auth_ldap/backend.py" in __init__
93. self.ldap = self.ldap_module()
File "/usr/local/lib/python2.6/dist-packages/django_auth_ldap-1.1.1-py2.6.egg/django_auth_ldap/backend.py" in ldap_module
104. return _LDAPConfig.get_ldap(options)
File "/usr/local/lib/python2.6/dist-packages/django_auth_ldap-1.1.1-py2.6.egg/django_auth_ldap/config.py" in get_ldap
74. cls.ldap.set_option(opt, value)
File "/usr/lib/python2.6/dist-packages/ldap/functions.py" in set_option
124. _ldap_function_call(_ldap.set_option,option,invalue)
File "/usr/lib/python2.6/dist-packages/ldap/functions.py" in _ldap_function_call
57. result = func(*args,**kwargs)
Exception Type: TypeError at /login/
Exception Value: an integer is required
答案 0 :(得分:0)
您的LDAP服务器抱怨AUTH_LDAP_GLOBAL_OPTIONS中的一个键/值对。确保使用ldap.OPT_*
常量作为字典键。