diff options
author | Marcin Kuzminski <marcin@python-works.com> | 2010-11-26 23:49:19 +0100 |
---|---|---|
committer | Marcin Kuzminski <marcin@python-works.com> | 2010-11-26 23:49:19 +0100 |
commit | 90c56ace9d30604f19a99d7d9d5c91a295fe2ae4 (patch) | |
tree | 176d93a6fb7045fc8d4c1531123ec8edfa641782 /rhodecode/model/forms.py | |
parent | 4cf1e71aabe1332a9715da2ad7c596dc2bb460a8 (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.py | 22 |
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 |