From 03b703aea216f5acb787c5b79777b0211178b133 Mon Sep 17 00:00:00 2001 From: kakwa Date: Tue, 26 May 2015 00:34:56 +0200 Subject: [PATCH] adding misc --- misc/debug_ldapbackend.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/misc/debug_ldapbackend.py b/misc/debug_ldapbackend.py index ec09b83..ce5eb00 100644 --- a/misc/debug_ldapbackend.py +++ b/misc/debug_ldapbackend.py @@ -11,6 +11,7 @@ from ldapcherry.backend.backendLdap import Backend from ldapcherry import syslog_error from ldapcherry.exceptions import * import cherrypy +import logging from ldap import SERVER_DOWN cfg = { @@ -26,12 +27,31 @@ cfg = { 'user_filter_tmpl' : '(uid=%(username)s)', 'group_filter_tmpl' : '(member=%(userdn)s)', 'search_filter_tmpl' : '(|(uid=%(searchstring)s*)(sn=%(searchstring)s*))', - +'objectclasses' : 'top, person, organizationalPerson, simpleSecurityObject, posixAccount', +'dn_user_attr' : 'uid', } +def syslog_error(msg='', context='', + severity=logging.INFO, traceback=False): + pass + cherrypy.log.error = syslog_error attr = ['shéll', 'cn', 'uid', 'uidNumber', 'gidNumber', 'home', 'userPassword', 'givenName', 'email', 'sn'] +cherrypy.log.error = syslog_error + inv = Backend(cfg, cherrypy.log, 'ldap', attr) print inv.get_user('jwatson') -print inv.search('smit') +print inv.get_user('test') +#print inv.search('smit') +user = { +'uid': 'test', +'sn': 'test', +'cn': 'test', +'userPassword': 'test', +'uidNumber': '42', +'gidNumber': '42', +'homeDirectory': '/home/test/' +} +inv.add_user(user) +inv.del_user('test')