我怀疑它是AUTH_LDAP_GROUP_TYPE
你正在使用的。我也在使用这个库,并让它同步组/成员资格。这是我对库的设置的完整转储:
AUTH_LDAP_START_TLS = True
AUTH_LDAP_SERVER_URI = 'xxxx'
AUTH_LDAP_GLOBAL_OPTIONS = {
ldap.OPT_X_TLS_REQUIRE_CERT: ldap.OPT_X_TLS_NEVER
}
AUTH_LDAP_BIND_DN = 'yyyy'
AUTH_LDAP_BIND_PASSWORD = 'zzzz'
AUTH_LDAP_USER_SEARCH = LDAPSearchUnion(
LDAPSearch(
'OU=OurCorp,DC=foo,DC=bar,DC=com',
ldap.SCOPE_SUBTREE,
filterstr='(uid=%(user)s)'
),
)
AUTH_LDAP_USER_ATTR_MAP = {
"first_name": "givenName",
"last_name": "sn",
"email": "mail",
}
AUTH_LDAP_GROUP_TYPE = ActiveDirectoryGroupType()
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
'OU=Security Groups,OU=Users and Groups,OU=OurCorp,DC=foo,DC=bar,DC=com',
ldap.SCOPE_SUBTREE,
'(objectClass=group)'
)
AUTH_LDAP_MIRROR_GROUPS = True
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
'is_staff': [ # Allow login to the Django admin site
'CN=Our-Staff-Group,OU=Security Groups,OU=Users and Groups,OU=OurCorp,DC=foo,DC=bar,DC=com',
],
'is_superuser': [ # Implicitly grant ALL permissions to members of these groups
'CN=Our-Superuser-Group,OU=Security Groups,OU=Users and Groups,OU=OurCorp,DC=foo,DC=bar,DC=com'
],
}
正如我所提到的,我认为这AUTH_LDAP_GROUP_TYPE
可能是您的问题,但这可能取决于您自己的 AD 设置。