【问题标题】:django_auth_ldap - AUTH_LDAP_REQUIRE_GROUPdjango_auth_ldap - AUTH_LDAP_REQUIRE_GROUP
【发布时间】:2018-04-23 16:12:13
【问题描述】:

我正在使用 django_auth_ldap。登录而不检查组可以正常工作。

但尝试使用已添加到 LDAP 上的组 example_group 的用户 example_user 登录并设置 AUTH_LDAP_REQUIRE_GROUP 失败。

settings.py

AUTH_LDAP_SERVER_URI = "ldap://ldap.example.com"
AUTH_LDAP_START_TLS = True

AUTH_LDAP_BIND_DN = ""
AUTH_LDAP_BIND_PASSWORD = ""
AUTH_LDAP_USER_SEARCH = LDAPSearch("cn=users,dc=example,dc=com",
    ldap.SCOPE_SUBTREE, "(uid=%(user)s)")



# Set up the basic group parameters.
AUTH_LDAP_GROUP_SEARCH = LDAPSearch("cn=example_group,cn=groups,dc=example,dc=com",
    ldap.SCOPE_SUBTREE, "(objectClass=groupOfNames)"
)

AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="cn")


AUTH_LDAP_REQUIRE_GROUP = "cn=example_group,cn=groups,dc=example,dc=com"

来自日志:

search_s('cn=users,dc=example,dc=com', 2, '(uid=%(user)s)') returned 1 objects: cn=example_user,cn=users,dc=example,dc=com
cn=example_user,cn=users,dc=example,dc=com is not a member of cn=example_group,cn=groups,dc=example,dc=com
Authentication failed for example_user: user does not satisfy AUTH_LDAP_REQUIRE_GROUP

$ ldapsearch -x -h ldap.example.com b"cn=example_group,cn=groups,dc=example,dc=com"

ldap_bind: Success (0)
    [...]
# extended LDIF
#
# LDAPv3
# base <cn=example_group,cn=groups,dc=example,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# example_group, Groups, example.com
dn: cn=example_group,cn=Groups,dc=example,dc=com
cn: example_group
objectclass: top
objectclass: groupOfUniqueNames
objectclass: orclGroup
description: [...]
displayname: example_group
orclisvisible: true
uniquemember: cn=example_user,cn=users,dc=example,dc=com

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

【问题讨论】:

    标签: django ldap django-auth-ldap


    【解决方案1】:

    它正在进行以下更改:

    settings.py

    from django_auth_ldap.config import LDAPSearch, GroupOfUniqueNamesType
    
    
    
    AUTH_LDAP_GROUP_SEARCH = LDAPSearch( "cn=example_group,cn=groups,dc=example,dc=com",
        #ldap.SCOPE_SUBTREE, "(objectClass=groupOfNames)"
        ldap.SCOPE_SUBTREE, "(objectClass=orclGroup)"
    )
    
    #AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="cn")
    AUTH_LDAP_GROUP_TYPE = GroupOfUniqueNamesType(name_attr="cn")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-02
      相关资源
      最近更新 更多