Author: tmckay
Date: 2012-05-02 13:21:05 +0000 (Wed, 02 May 2012)
New Revision: 5354
Modified:
trunk/cumin/python/cumin/authenticator.py
Log:
Allow multiple occurrences of %s in filterstr, all to be replaced with
username.
Modified: trunk/cumin/python/cumin/authenticator.py
===================================================================
--- trunk/cumin/python/cumin/authenticator.py 2012-05-02 12:50:21 UTC (rev 5353)
+++ trunk/cumin/python/cumin/authenticator.py 2012-05-02 13:21:05 UTC (rev 5354)
@@ -55,11 +55,18 @@
return False
return conn
+ def _gen_filter(self, filterstr, value):
+ count = filterstr.count("%s")
+ if count > 0:
+ vals = (value,) * count
+ return filterstr % vals
+ return filterstr
+
def _find_user(self, user):
res = False
conn = self.__prep_con()
if conn:
- filter = self.url.filterstr % user
+ filter = self._gen_filter(self.url.filterstr, user)
try:
res = conn.search_s(self.url.dn, self.url.scope, filter)
except Exception, e:
@@ -92,7 +99,7 @@
conn = self.__prep_con()
error = not conn
if not error:
- filter = self.url.filterstr % '*'
+ filter = self._gen_filter(self.url.filterstr, "*")
try:
res = conn.search_s(self.url.dn, self.url.scope, filter)
except Exception, e:
Show replies by date