2012-08-15 49 views
0

使用Django 1.4和django-auth-ldap 1.1,我試圖配置我的web應用程序來根據LDAP服務對用戶進行身份驗證。在登錄表單中提供正確的登錄憑據,我得到這個錯誤: -django-auth-ldap」需要一個整數「錯誤

類型錯誤在/登錄/

的整數需要

請求方法:POST

請求URL:http://mydomain.com:8000/login/

Django的版本:1.4

異常類型:類型錯誤

異常值:

的整數需要

異常位置:在_ldap_function_call /usr/lib/python2.6/dist-packages/ldap/functions.py 57行 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

需要更多回溯。相關部分可能是將表單值傳遞給ldap包的地方。形式值中的某些東西並不是它所期待的。 – jdi 2012-08-15 20:10:45

+0

您需要發佈處理用戶登錄的代碼。 – 2012-08-15 20:18:54

+0

添加了追溯信息。 – bzo 2012-08-16 15:00:14

回答

0

LDAP服務器抱怨你AUTH_LDAP_GLOBAL_OPTIONS鍵/值對之一。確保你使用ldap.OPT_*常量作爲字典鍵。

相關問題