[Zope-CVS] SVN: ldapadapter/trunk/utility.py Added test adapter fro testing

Roger Ineichen roger at projekt01.ch
Sun Oct 10 09:00:50 EDT 2004


Log message for revision 27894:
  Added test adapter fro testing
  Added test view for testing adapter/connection


Changed:
  U   ldapadapter/trunk/utility.py


-=-
Modified: ldapadapter/trunk/utility.py
===================================================================
--- ldapadapter/trunk/utility.py	2004-10-10 12:45:00 UTC (rev 27893)
+++ ldapadapter/trunk/utility.py	2004-10-10 13:00:50 UTC (rev 27894)
@@ -54,9 +54,10 @@
 class LDAPAdapter(object):
     implements(ILDAPAdapter)
 
-    def __init__(self, host='localhost', port=389, bindDN='', bindPassword='', useSSL=False):
+    def __init__(self, host='localhost', port=389, baseDN='', bindDN='', bindPassword='', useSSL=False):
         self.host = host
         self.port = port
+        self.baseDN = baseDN
         self.bindDN = bindDN
         self.bindPassword = bindPassword
         self.useSSL = useSSL
@@ -78,6 +79,9 @@
             dn = self.bindDN
         conn.simple_bind_s(dn, password)
         # May raise INVALID_CREDENTIALS, SERVER_DOWN, ...
+        
+        # set baseDN to the wrapper class
+        conn.baseDN = self.baseDN
 
         return LDAPConnection(conn)
 
@@ -93,19 +97,20 @@
         """Returns the server url from the host and port info.
         ldap[s]://host:port
         """
+        port = 389
         url = url.strip()
-        urlReg = '^ldap://[a-zA-Z0-9\-\.]+:[\d]{1,5}'
-        if re.match(urlReg, url):
-            urlList = url.split(':')
-            if len(urlList) >= 2:
-                useSSL = urlList[0].endswith('s')
-                host = urlList[1][2:]
-                if len(urlList) == 3:
-                    port = int(urlList[2])
-            else:
-                URLFormatError(LDAP_url_format_error)
+        #urlReg = '^ldap://[a-zA-Z0-9\-\.]+:[\d]{1,5}'
+        #if re.match(urlReg, url):
+        urlList = url.split(':')
+        if len(urlList) >= 2:
+            useSSL = urlList[0].endswith('s')
+            host = urlList[1][2:]
+            if len(urlList) == 3:
+                port = int(urlList[2])
         else:
-            raise URLFormatError(LDAP_url_format_error)
+            URLFormatError(LDAP_url_format_error)
+        #else:
+        #    raise URLFormatError(LDAP_url_format_error)
          
         self.host = host
         self.port = port
@@ -117,6 +122,7 @@
 
     def __init__(self, conn):
         self.conn = conn
+        self.baseDN = None
 
     def add(self, dn, entry):
         attrs_list = []



More information about the Zope-CVS mailing list