1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 09:24:21 +01:00

fix misc example for ldap backend usage

This commit is contained in:
kakwa 2015-06-15 07:31:44 +02:00
parent 24d415280a
commit f79121e1e5

View File

@ -15,20 +15,23 @@ import logging
from ldap import SERVER_DOWN from ldap import SERVER_DOWN
cfg = { cfg = {
'module' : 'ldapcherry.backend.ldap', 'module' : 'ldapcherry.backend.ldap',
'groupdn' : 'ou=Groups,dc=example,dc=org', 'groupdn' : 'ou=Groups,dc=example,dc=org',
'userdn' : 'ou=People,dc=example,dc=org', 'userdn' : 'ou=People,dc=example,dc=org',
'binddn' : 'cn=dnscherry,dc=example,dc=org', 'binddn' : 'cn=dnscherry,dc=example,dc=org',
'password' : 'password', 'password' : 'password',
'uri' : 'ldap://ldap.ldapcherry.org:390', 'uri' : 'ldap://ldap.ldapcherry.org:390',
'ca' : './tests/test_env/etc/ldapcherry/TEST-cacert.pem', 'ca' : './tests/test_env/etc/ldapcherry/TEST-cacert.pem',
'starttls' : 'off', 'starttls' : 'off',
'checkcert' : 'off', 'checkcert' : 'off',
'user_filter_tmpl' : '(uid=%(username)s)', 'user_filter_tmpl' : '(uid=%(username)s)',
'group_filter_tmpl' : '(member=%(userdn)s)', 'group_filter_tmpl' : '(member=%(userdn)s)',
'search_filter_tmpl' : '(|(uid=%(searchstring)s*)(sn=%(searchstring)s*))', 'search_filter_tmpl' : '(|(uid=%(searchstring)s*)(sn=%(searchstring)s*))',
'objectclasses' : 'top, person, organizationalPerson, simpleSecurityObject, posixAccount', 'objectclasses' : 'top, person, organizationalPerson, simpleSecurityObject, posixAccount',
'dn_user_attr' : 'uid', 'dn_user_attr' : 'uid',
'group_attr.uniqMember' : "%(dn)s",
'group_attr.memberUid' : "%(uid)s",
} }
def syslog_error(msg='', context='', def syslog_error(msg='', context='',
@ -40,7 +43,7 @@ attr = ['shéll', 'cn', 'uid', 'uidNumber', 'gidNumber', 'home', 'userPassword',
cherrypy.log.error = syslog_error cherrypy.log.error = syslog_error
inv = Backend(cfg, cherrypy.log, 'ldap', attr) inv = Backend(cfg, cherrypy.log, 'ldap', attr, 'uid')
print inv.get_user('jwatson') print inv.get_user('jwatson')
print inv.get_groups('jwatson') print inv.get_groups('jwatson')
print inv.search('smit') print inv.search('smit')
@ -57,3 +60,6 @@ inv.add_user(user)
print inv.get_user('test') print inv.get_user('test')
print inv.get_groups('test') print inv.get_groups('test')
inv.del_user('test') inv.del_user('test')
print inv.group_attrs