aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/forms.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2010-11-26 23:49:19 +0100
committerMarcin Kuzminski <marcin@python-works.com>2010-11-26 23:49:19 +0100
commit90c56ace9d30604f19a99d7d9d5c91a295fe2ae4 (patch)
tree176d93a6fb7045fc8d4c1531123ec8edfa641782 /rhodecode/model/forms.py
parent4cf1e71aabe1332a9715da2ad7c596dc2bb460a8 (diff)
fixes #77 and adds extendable base Dn with custom uid specification
--HG-- branch : beta
Diffstat (limited to 'rhodecode/model/forms.py')
-rw-r--r--rhodecode/model/forms.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py
index 0e20c63a..5ed32036 100644
--- a/rhodecode/model/forms.py
+++ b/rhodecode/model/forms.py
@@ -300,6 +300,26 @@ class LdapLibValidator(formencode.validators.FancyValidator):
raise LdapImportError
return value
+class BaseDnValidator(formencode.validators.FancyValidator):
+
+ def to_python(self, value, state):
+
+ try:
+ value % {'user':'valid'}
+
+ if value.find('%(user)s') == -1:
+ raise formencode.Invalid(_("You need to specify %(user)s in "
+ "template for example uid=%(user)s "
+ ",dc=company...") ,
+ value, state)
+
+ except KeyError:
+ raise formencode.Invalid(_("Wrong template used, only %(user)s "
+ "is an valid entry") ,
+ value, state)
+
+ return value
+
#===============================================================================
# FORMS
#===============================================================================
@@ -457,6 +477,6 @@ def LdapSettingsForm():
ldap_ldaps = StringBoolean(if_missing=False)
ldap_dn_user = UnicodeString(strip=True,)
ldap_dn_pass = UnicodeString(strip=True,)
- ldap_base_dn = UnicodeString(strip=True,)
+ ldap_base_dn = All(BaseDnValidator, UnicodeString(strip=True,))
return _LdapSettingsForm