使用Django Auth Ldap将LDAP用户映射到Django用户 [英] Mapping LDAP users to Django users with Django Auth Ldap

查看:804
本文介绍了使用Django Auth Ldap将LDAP用户映射到Django用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Django 1.3和Django Auth Ldap 1.0.6。我试图让具有LDAP服务器(管理员)特殊状态的用户在我的Django应用程序中具有相同的状态。



这些是我当前的设置:

  AUTH_LDAP_SERVER_URI ='ldap://path.to.server'

AUTH_LDAP_BIND_DN =''
AUTH_LDAP_BIND_PASSWORD =''
AUTH_LDAP_USER_DN_TEMPLATE ='uid =%(user)s,cn = users,dc = server,dc = location,dc = lan'
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
'cn = groups,dc = server,dc = location,dc = lan',
ldap.SCOPE_SUBTREE,
'(objectClass = groupOfNames)',

AUTH_LDAP_USER_ATTR_MAP = {
'first_name':'givenName',
'last_name':'sn',
}
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
#'is_active':'cn = groups ,dc = server,dc = location,dc = lan',
#'is_staff':'cn = admin,cn = groups,dc = server,dc = location,dc = lan',
#'is_superuser':'cn = admin,cn = groups,dc = server,dc = location,dc = lan',
}
AUTH_LDAP_ALWAYS_UPDATE_USER = True
AUTH_LDAP_MIRROR_GROUPS = True
AUTH_LDAP_FIND_GROUPS_PERMS = True

权限未更新。如果我取消注释FLAGS_BY_GROUP中的值,我无法再验证(错误消息说用户和密码不匹配)。我试过没有最后一个设置相同的结果。



任何想法都非常感激。

解决方案

在psagers的提示的帮助下,我设法找到我的问题的答案。
首先,我使用Open Directory,所以我需要使用AUTH_LDAP_GROUP_TYPE = PosixGroupType(name_attr ='cn')而不是GroupOfNamesType()。
第二,将'is_active'标志映射到整个'groups'容器是没有意义的,因为我使用它时无法登录,所以我把它取出来。


I'm using Django 1.3 and Django Auth Ldap 1.0.6. and I'm trying to have the users who have a special status on the LDAP Server (admins) have the same status in my Django application.

These are my current settings:

AUTH_LDAP_SERVER_URI = 'ldap://path.to.server'

AUTH_LDAP_BIND_DN = ''
AUTH_LDAP_BIND_PASSWORD = ''
AUTH_LDAP_USER_DN_TEMPLATE = 'uid=%(user)s,cn=users,dc=server,dc=location,dc=lan'
AUTH_LDAP_GROUP_SEARCH = LDAPSearch(
                             'cn=groups,dc=server,dc=location,dc=lan',
                             ldap.SCOPE_SUBTREE,
                             '(objectClass=groupOfNames)',
)
AUTH_LDAP_USER_ATTR_MAP = {
    'first_name': 'givenName',
    'last_name': 'sn',
}
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
    #'is_active': 'cn=groups,dc=server,dc=location,dc=lan',
    #'is_staff': 'cn=admin,cn=groups,dc=server,dc=location,dc=lan',
    #'is_superuser': 'cn=admin,cn=groups,dc=server,dc=location,dc=lan',
}
AUTH_LDAP_ALWAYS_UPDATE_USER = True
AUTH_LDAP_MIRROR_GROUPS = True
AUTH_LDAP_FIND_GROUPS_PERMS = True

Permissions aren't updated. If I uncomment the values in FLAGS_BY_GROUP, I can't authenticate any more (the error message says that the user and password don't match). I tried without the last setting with the same results.

Any ideas are highly appreciated.

解决方案

With the help of psagers' tips, I managed to find the answer to my issue. First, I'm using Open Directory, so I need to use AUTH_LDAP_GROUP_TYPE = PosixGroupType(name_attr='cn') instead of GroupOfNamesType(). Second, mapping the 'is_active' flag to the entire 'groups' container doesn't make sense, because I can't login when I use it, so I took it out.

这篇关于使用Django Auth Ldap将LDAP用户映射到Django用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆