Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 配置LDAP_Django_Ldap_Server - Fatal编程技术网

Django 配置LDAP

Django 配置LDAP,django,ldap,server,Django,Ldap,Server,我正在构建的应用程序需要LDAP身份验证。我通过apache托管我的应用程序,我使用ssl…如果这有帮助的话 我已经安装了所有库并遵循了基本的配置步骤,但是在尝试了一些与shell相关的测试之后,我甚至无法连接到ldap服务器 我以前从未这样做过,因此非常感谢您的帮助 让我知道我是否应该张贴任何额外的材料 主要教程: 到目前为止我使用的测试: 一经改变ldap://128.114.119.108:636 到ldaps://128.114.119.108:636 自ssl >>>

我正在构建的应用程序需要LDAP身份验证。我通过apache托管我的应用程序,我使用ssl…如果这有帮助的话

我已经安装了所有库并遵循了基本的配置步骤,但是在尝试了一些与shell相关的测试之后,我甚至无法连接到ldap服务器

我以前从未这样做过,因此非常感谢您的帮助

让我知道我是否应该张贴任何额外的材料

主要教程:

到目前为止我使用的测试:

一经改变ldap://128.114.119.108:636 到ldaps://128.114.119.108:636 自ssl

>>> import ldap
>>> server = 'ldaps://xxx.xxx.xxx.xxx:qqq'
>>> user_dn = 'uid=ajanakos,ou=people,dc=ucsc,dc=edu'
>>> password = 'xxxxxxxxx'
>>> con = ldap.initialize(server)
>>> con.simple_bind_s(user_dn, password)
SERVER_DOWN: {'info': 'TLS: hostname does not match CN in peer certificate', 'desc': "Can't contact LDAP server"}
设置.py

import ldap
from django_auth_ldap.config import LDAPSearch

AUTH_LDAP_SERVER_URI = "ldaps://xxx.xxx.xxx.xxx:qqq"

AUTH_LDAP_BIND_DN = ""
AUTH_LDAP_BIND_PASSWORD = ""
AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=people,dc=ucsc,dc=edu", ldap.SCOPE_SUBTREE, "(uid=%(user)s)")

AUTHENTICATION_BACKENDS = (
    'django_auth_ldap.backend.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
)
views.py-登录函数

from django.shortcuts import render
from models import search
from forms import Form
from dmca import settings
from django.contrib.auth import authenticate, login, logout
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth.decorators import login_required
import credentials as c
import base64
import psycopg2
import time
import datetime

# Create your views here.

def Login(request):
    if request.method == "POST":
        username = request.POST['username']
        password = request.POST['password']
        print 'text'
        user = authenticate(username=username, password=password)
        if user is not None:
            if user.is_active:
                login(request, user)
                return HttpResponseRedirect('/lookup')
            else:
                return HttpResponse("Inactive user.")
        else:
            return HttpResponseRedirect(settings.LOGIN_URL)

     return render(request, "dmca_app/login.html", {})

我注意到您正在尝试使用LDAP(即通过TLS的LDAP)连接到LDAP服务器。这要求您配置一个至少包含证书的信任库,以验证服务器的证书。

能否将我们链接到您正在学习的教程,并向我们展示您尝试连接时得到的响应?我的主要教程:谢谢!那么,当你说你连连接都无法连接的时候--你在shell上得到了什么样的消息?如果你阅读了我发布的测试链接。。对于第一种方法,匿名函数不存在,第二种方法不起作用。。我会把我实际输入的东西贴在网上。我需要使用主机名而不是IP来同意证书:)@ajanakos你能发布你的
ldap
的工作设置吗?