From 45a40635bb6867f55f757413776c2374ae07a888 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Tue, 7 Jul 2009 22:54:07 -0400 Subject: Add class variable to indicate whether SSL is required or not. Older python-ldap versions will crash if you call ldap.get_option() on a value that has not been set. --- ipaserver/plugins/ldap2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ipaserver') diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py index 586c31f95..43cc6b976 100644 --- a/ipaserver/plugins/ldap2.py +++ b/ipaserver/plugins/ldap2.py @@ -168,14 +168,14 @@ class ldap2(CrudBackend, Encoder): self._host = api.env.ldap_host self._port = api.env.ldap_port self._schema = _schema + self._ssl = False CrudBackend.__init__(self) def __del__(self): self.disconnect() def __str__(self): - using_cacert = bool(_ldap.get_option(_ldap.OPT_X_TLS_CACERTFILE)) - return _get_url(self._host, self._port, using_cacert) + return _get_url(self._host, self._port, self._ssl) @encode_args(3, 4, 'bind_dn', 'bind_pw') def create_connection(self, host=None, port=None, ccache=None, @@ -208,8 +208,10 @@ class ldap2(CrudBackend, Encoder): if tls_cacertfile is not None: _ldap.set_option(_ldap.OPT_X_TLS_CACERTFILE, tls_cacertfile) + self._ssl = True if tls_certfile is not None: _ldap.set_option(_ldap.OPT_X_TLS_CERTFILE, tls_certfile) + self._ssl = True if tls_keyfile is not None: _ldap.set_option(_ldap.OPT_X_TLS_KEYFILE, tls_keyfile) -- cgit