##// END OF EJS Templates
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
marcink -
r1145:9a994632 default
parent child Browse files
Show More
@@ -68,10 +68,11 class LdapSettingsController(BaseControl
68 68 """POST ldap create and store ldap settings"""
69 69
70 70 settings_model = SettingsModel()
71 _form = LdapSettingsForm()()
71 post_data = dict(request.POST)
72 _form = LdapSettingsForm(post_data.get('ldap_active'))()
72 73
73 74 try:
74 form_result = _form.to_python(dict(request.POST))
75 form_result = _form.to_python(post_data)
75 76 try:
76 77
77 78 for k, v in form_result.items():
@@ -300,10 +300,13 class LdapLibValidator(formencode.valida
300 300 raise LdapImportError
301 301 return value
302 302
303 class BaseDnValidator(formencode.validators.FancyValidator):
303 def BaseDnValidator(ldap_enable):
304 class _BaseDnValidator(formencode.validators.FancyValidator):
304 305
305 306 def to_python(self, value, state):
306 307
308 if not ldap_enable:
309 return ''
307 310 try:
308 311 value % {'user':'valid'}
309 312
@@ -319,7 +322,7 class BaseDnValidator(formencode.validat
319 322 value, state)
320 323
321 324 return value
322
325 return _BaseDnValidator
323 326 #===============================================================================
324 327 # FORMS
325 328 #===============================================================================
@@ -467,7 +470,7 def DefaultPermissionsForm(perms_choices
467 470 return _DefaultPermissionsForm
468 471
469 472
470 def LdapSettingsForm():
473 def LdapSettingsForm(ldap_enable):
471 474 class _LdapSettingsForm(formencode.Schema):
472 475 allow_extra_fields = True
473 476 filter_extra_fields = True
@@ -478,6 +481,6 def LdapSettingsForm():
478 481 ldap_ldaps = StringBoolean(if_missing=False)
479 482 ldap_dn_user = UnicodeString(strip=True,)
480 483 ldap_dn_pass = UnicodeString(strip=True,)
481 ldap_base_dn = All(BaseDnValidator, UnicodeString(strip=True,))
484 ldap_base_dn = All(BaseDnValidator(ldap_enable), UnicodeString(strip=True,))
482 485
483 486 return _LdapSettingsForm
General Comments 0
You need to be logged in to leave comments. Login now