推荐学习书目
› 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 · Nov 10, 2017 · 2458 views
    This topic created in 3240 days ago, the information mentioned may be changed or developed.
    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 是哪里写的有问题吗
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1022 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:18 · PVG 07:18 · LAX 16:18 · JFK 19:18
    ♥ Do have faith in what you're doing.