V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
caowenhao
V2EX  ›  Python

Django 如何使用 LDAP 验证

  •  
  •   caowenhao · 2017-11-10 09:10:00 +08:00 · 1895 次点击
    这是一个创建于 2414 天前的主题,其中的信息可能已经有所发展或是发生改变。
    import ldap
    from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion

    # Baseline configuration.
    AUTH_LDAP_SERVER_URI = "ldap://192.168.0.100:389"
    AUTH_LDAP_BIND_DN = 'cn=caowenhao,ou=IT 管理部,ou=GOA,ou=Company,dc=normstar,dc=com'
    AUTH_LDAP_BIND_PASSWORD = '1qaz@WSX'
    AUTH_LDAP_USER_SEARCH = LDAPSearchUnion(
    LDAPSearch("ou=IT 管理部,ou=GOA,ou=Company,dc=normstar,dc=com",ldap.SCOPE_SUBTREE, "(&(objectClass=user)(sAMAccountName=%(user)s))"),
    LDAPSearch("ou=jiaowu,ou=Company,dc=normstar,dc=com",ldap.SCOPE_SUBTREE, "(&(objectClass=user)(sAMAccountName=%(user)s))"),
    )

    AUTH_LDAP_USER_ATTR_MAP = {
    "first_name": "first_name",
    "last_name": "last_name",
    "email": "mail"
    }


    AUTHENTICATION_BACKENDS = (
    'django_auth_ldap.backend.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
    )在 seeting.py 中加入上面的配置后,登陆的时候会报错:ImportError at /login/cannot import name SiteProfileNotAvailable 是哪里写的有问题吗
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2955 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 85ms · UTC 12:16 · PVG 20:16 · LAX 05:16 · JFK 08:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.