]> git.ipfire.org Git - ipfire.org.git/commitdiff
Use correct python module
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 11 Oct 2018 10:39:04 +0000 (11:39 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 11 Oct 2018 10:39:04 +0000 (11:39 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
requirements.txt
src/backend/accounts.py

index f70ac158da38b0ffe0bacb83b9c88ee238328c29..35cc3eb421b4235503f4fa03b2e43354c9ef449e 100644 (file)
@@ -3,7 +3,6 @@ feedparser==5.2.1
 file-magic==0.4.0
 html5lib==1.0.1
 iso3166==0.9
-ldap==1.0.2
 ldap3==2.5.1
 markdown2==2.3.6
 pciutils==2.3.7
@@ -11,7 +10,9 @@ Pillow==5.3.0
 psycopg2-binary==2.7.5
 py-dateutil==2.2
 pyasn1==0.4.4
+pyasn1-modules==0.2.2
 pycurl==7.43.0
+python-ldap==3.1.0
 python3-memcached==1.51
 six==1.11.0
 textile==3.0.3
index 7490e91552979bbf7ef7a57fafb17d8810ab3cac..d322198bedadd52c774b82bc2187e2cd7c1bfc7f 100644 (file)
@@ -18,20 +18,19 @@ class Accounts(Object):
 
                return iter(sorted(accounts))
 
-       @property
+       @lazy_property
        def ldap(self):
-               if not hasattr(self, "_ldap"):
-                       # Connect to LDAP server
-                       ldap_uri = self.settings.get("ldap_uri")
-                       self._ldap = ldap.initialize(ldap_uri)
+               # Connect to LDAP server
+               ldap_uri = self.settings.get("ldap_uri")
+               conn = ldap.initialize(ldap_uri)
 
-                       # Bind with username and password
-                       bind_dn = self.settings.get("ldap_bind_dn")
-                       if bind_dn:
-                               bind_pw = self.settings.get("ldap_bind_pw", "")
-                               self._ldap.simple_bind(bind_dn, bind_pw)
+               # Bind with username and password
+               bind_dn = self.settings.get("ldap_bind_dn")
+               if bind_dn:
+                       bind_pw = self.settings.get("ldap_bind_pw", "")
+                       conn.simple_bind(bind_dn, bind_pw)
 
-               return self._ldap
+               return conn
 
        def _query(self, query, attrlist=None, limit=0):
                logging.debug("Performing LDAP query: %s" % query)
@@ -43,7 +42,8 @@ class Accounts(Object):
                                query, attrlist=attrlist, sizelimit=limit)
                except:
                        # Close current connection
-                       del self._ldap
+                       self.ldap.close()
+                       del self.ldap
 
                        raise