mirror of
https://github.com/kakwa/ldapcherry
synced 2025-07-04 20:37:48 +02:00
multiple changes
* change parameters name for Backend Ldap * fix default value handling in backends get_param * correct exception in backends get_param * fix syntaxe error * add backend name in test_BackendLdap.py
This commit is contained in:
parent
cb843a40e5
commit
93ed190913
6 changed files with 34 additions and 27 deletions
|
@ -24,11 +24,11 @@ class Backend:
|
|||
def rm_from_group(self):
|
||||
pass
|
||||
|
||||
def get_param(self, param, default=False):
|
||||
def get_param(self, param, default=None):
|
||||
if param in self.config:
|
||||
return self.config[param]
|
||||
elif default:
|
||||
elif not default is None:
|
||||
return default
|
||||
else:
|
||||
raise MissingParameter(self.backend_name+'.'+param, 'backends')
|
||||
raise MissingParameter('backends', self.backend_name+'.'+param)
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@ class Backend(ldapcherry.backend.Backend):
|
|||
self.config = config
|
||||
self._logger = logger
|
||||
self.backend_name = name
|
||||
self.binddn = self.get_param(binddn)
|
||||
self.ca = self.get_param(ca)
|
||||
self.checkcert = self.get_param(checkcert)
|
||||
self.starttls = self.get_param(starttls)
|
||||
self.uri = self.get_param(uri)
|
||||
self.user_filter_tmpl = self.get_param(user_filter_tmpl)
|
||||
self.binddn = self.get_param('binddn')
|
||||
self.ca = self.get_param('ca', False)
|
||||
self.checkcert = self.get_param('checkcert', 'on')
|
||||
self.starttls = self.get_param('starttls', 'off')
|
||||
self.uri = self.get_param('uri')
|
||||
self.user_filter_tmpl = self.get_param('user_filter_tmpl')
|
||||
|
||||
def auth(self, username, password):
|
||||
|
||||
|
@ -97,7 +97,7 @@ class Backend(ldapcherry.backend.Backend):
|
|||
else:
|
||||
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,ldap.OPT_X_TLS_DEMAND)
|
||||
|
||||
if self.starttls == 'on':
|
||||
if self.starttls == 'on':
|
||||
try:
|
||||
ldap_client.start_tls_s()
|
||||
except ldap.OPERATIONS_ERROR:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue