[Zope-CVS] SVN: ldapadapter/trunk/ Remove password in test view
Roger Ineichen
roger at projekt01.ch
Sun Oct 10 12:47:49 EDT 2004
Log message for revision 27923:
Remove password in test view
Remove unused attrs
Remove old regex and error handling code
Changed:
U ldapadapter/trunk/browser/check.pt
U ldapadapter/trunk/browser/check.py
U ldapadapter/trunk/check.py
U ldapadapter/trunk/utility.py
-=-
Modified: ldapadapter/trunk/browser/check.pt
===================================================================
--- ldapadapter/trunk/browser/check.pt 2004-10-10 16:38:00 UTC (rev 27922)
+++ ldapadapter/trunk/browser/check.pt 2004-10-10 16:47:49 UTC (rev 27923)
@@ -27,45 +27,18 @@
</tr>
<tr>
<td i18n:translate="">Bind DN</td>
- <td><span tal:content="python:hostinfo['baseDN']">baseDN</span></td>
- </tr>
- <tr>
- <td i18n:translate="">Base DN</td>
<td><span tal:content="python:hostinfo['bindDN']">bindDN</span></td>
</tr>
<tr>
- <td i18n:translate="">Bind password</td>
- <td><span tal:content="python:hostinfo['bindPassword']">bindPassword</span></td>
+ <td i18n:translate="">Use SSL</td>
+ <td><span tal:content="python:hostinfo['useSSL']">SSL</span></td>
</tr>
</tbody>
</table>
- <span i18n:translate="">
- For to test the authentication, you can set a username and password.<br />
- This usename and password has to be falid on the LDAP server.
- </span>
-
- <table id="sortable" class="listing" summary="LDAP Connection Test Data"
- i18n:attributes="summary">
- <thead>
- <tr>
- <th i18n:translate="">Description</th>
- <th i18n:translate="">Data</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td i18n:translate="">Bind DN</td>
- <td><input type="text" value="" name="bindDN"></td>
- </tr>
- <tr>
- <td i18n:translate="">Bind password</td>
- <td><input type="password" value="" name="bindPassword"></td>
- </tr>
- </tbody>
- </table>
<input type="hidden" value="Run" name="runtest">
- <input type="submit" value="Test" name="submit">
+ <input type="submit" value="Test default" name="runDefault">
+ <input type="submit" value="Test anonymous" name="runAnonymous">
<table id="sortable" class="listing" summary="LDAP Connection Report listing"
i18n:attributes="summary"
Modified: ldapadapter/trunk/browser/check.py
===================================================================
--- ldapadapter/trunk/browser/check.py 2004-10-10 16:38:00 UTC (rev 27922)
+++ ldapadapter/trunk/browser/check.py 2004-10-10 16:47:49 UTC (rev 27923)
@@ -13,13 +13,9 @@
##############################################################################
"""View Class for the Container's Contents view.
-$Id: check.py 26680 2004-07-22 16:31:38Z nicoe $
+$Id:$
"""
-from zope.exceptions import NotFoundError
-
-from zope.app import zapi
-from zope.app.size.interfaces import ISized
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.publisher.browser import BrowserView
from zope.app.i18n import ZopeMessageIDFactory as _
@@ -45,29 +41,34 @@
infoDict = {}
infoDict['host'] = self.context.host
infoDict['port'] = self.context.port
- infoDict['baseDN'] = self.context.baseDN
infoDict['bindDN'] = self.context.bindDN
infoDict['bindPassword'] = self.context.bindPassword
+ infoDict['useSSL'] = self.context.useSSL and 'Yes' or 'No'
return infoDict
def checkConnection(self):
"""Check connetction to the given LDAP server."""
- runtest = self.request.get('runtest', None)
- if runtest == "Run":
- dn = self.request.get('bindDN')
- pw = self.request.get('bindPassword')
-
- # get the ldapauth source
+ if self.request.get('runDefault', None):
+ dn = self.context.bindDN
+ pw = self.context.bindPassword
testadapter = ICheckLDAPAdapter(self.context)
-
- # test the connection to the LDAP server
self._addInfo("<strong>Test python connection and LDAP server binding</strong>")
self.report = self.report + testadapter.testConnection(dn, pw)
self._addInfo("<strong>Tests done</strong>")
self._addInfo(" ")
return self.report
+
+ elif self.request.get('runAnonymous', None):
+ dn = ''
+ pw = ''
+ testadapter = ICheckLDAPAdapter(self.context)
+ self._addInfo("<strong>Test python connection and LDAP server binding</strong>")
+ self.report = self.report + testadapter.testConnection(dn, pw)
+ self._addInfo("<strong>Tests done</strong>")
+ self._addInfo(" ")
+ return self.report
else:
return ""
Modified: ldapadapter/trunk/check.py
===================================================================
--- ldapadapter/trunk/check.py 2004-10-10 16:38:00 UTC (rev 27922)
+++ ldapadapter/trunk/check.py 2004-10-10 16:47:49 UTC (rev 27923)
@@ -13,7 +13,7 @@
##############################################################################
"""A plugable authentication module for LDAP.
-$Id: check.py 27204 2004-08-21 01:46:57Z nicoe $
+$Id:$
"""
from zope.security.proxy import removeSecurityProxy
@@ -33,22 +33,23 @@
def testConnection(self, bindDN, bindPassword):
self.report = []
adapter = removeSecurityProxy(self.context)
- self.report.append("Start check connection")
+ serverURL = adapter.getServerURL()
+ self.report.append("... start check connection")
try:
self.report.append("... try connect with:")
+ self.report.append("... serverURL = %s" % serverURL)
self.report.append("... bindDN = %s" % bindDN)
- self.report.append("... bindPassword = %s" % bindPassword)
-
connection = adapter.connect(bindDN, bindPassword)
-
- if connection != None:
- self.report.append("... <strong>Connecting failed!</strong>")
+
+ if connection:
+ self.report.append("... <strong>connection OK!</strong>")
+ self.report.append("... <strong>%s</strong>" % connection)
else:
- self.report.append("... <strong>OK!</strong>")
-
- return report
+ self.report.append("... <strong>Connection None</strong>")
+ return self.report
+
except:
self.report.append("... <strong>Test failed!</strong>")
return self.report
Modified: ldapadapter/trunk/utility.py
===================================================================
--- ldapadapter/trunk/utility.py 2004-10-10 16:38:00 UTC (rev 27922)
+++ ldapadapter/trunk/utility.py 2004-10-10 16:47:49 UTC (rev 27923)
@@ -63,8 +63,7 @@
self.bindPassword = bindPassword
def connect(self, dn=None, password=None):
- proto = self.useSSL and 'ldaps' or 'ldap'
- conn_str = '%s://%s:%s/' % (proto, self.host, self.port)
+ conn_str = self.getServerURL()
conn = ldap.initialize(conn_str)
try:
conn.set_option(OPT_PROTOCOL_VERSION, VERSION3)
@@ -83,13 +82,11 @@
return LDAPConnection(conn)
- def _getServerURL(self):
+ def getServerURL(self):
"""Returns the server url from the host and port info."""
- if self.useSSL:
- protocol = 'ldaps://'
- else:
- protocol = 'ldap://'
- return protocol + self.host +':'+ str(self.port)
+ proto = self.useSSL and 'ldaps' or 'ldap'
+ return '%s://%s:%s' % (proto, self.host, self.port)
+
def _setServerURL(self, url):
"""Returns the server url from the host and port info.
@@ -97,8 +94,6 @@
"""
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')
@@ -107,8 +102,6 @@
port = int(urlList[2])
else:
LDAPURIParseError(LDAP_uri_parse_error)
- #else:
- # raise LDAPURIParseError(LDAP_uri_parse_error)
self.host = host
self.port = port
@@ -180,6 +173,6 @@
implements(IManageableLDAPAdapter)
- serverURL = property(LDAPAdapter._getServerURL, LDAPAdapter._setServerURL)
+ serverURL = property(LDAPAdapter.getServerURL, LDAPAdapter._setServerURL)
bindDN = u''
bindPassword = u''
More information about the Zope-CVS
mailing list