From 07abb7eed67ee1c6ac36119312ed9eefe9e33ecf Mon Sep 17 00:00:00 2001
From: Marco R <xoot123@yahoo.it>
Date: Tue, 20 Mar 2018 09:42:57 +0100
Subject: [PATCH 1/5] Fix checkboxes sent value

---
 server/src/main/webapp/public/resources/js/newuser.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/server/src/main/webapp/public/resources/js/newuser.js b/server/src/main/webapp/public/resources/js/newuser.js
index d24d486b8..ed7d33be4 100644
--- a/server/src/main/webapp/public/resources/js/newuser.js
+++ b/server/src/main/webapp/public/resources/js/newuser.js
@@ -48,7 +48,14 @@ PWM_NEWUSER.makeFormData=function() {
 
     for (var i = 0; i < newUserForm.elements.length; i++ ) {
         var loopElement = newUserForm.elements[i];
-        paramData[loopElement.name] = loopElement.value;
+        
+        if(loopElement.type == "checkbox") {
+        	if(loopElement.checked) {
+        		paramData[loopElement.name] = loopElement.value;
+        	}
+        } else {
+        	paramData[loopElement.name] = loopElement.value;
+        }
     }
 
     return paramData;

From f966083b50ab3eb7d4880c257ac2a5c8e7b6209e Mon Sep 17 00:00:00 2001
From: Marco R <xoot123@yahoo.it>
Date: Tue, 20 Mar 2018 09:51:56 +0100
Subject: [PATCH 2/5] Let checkboxes be a required field

---
 server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp           | 3 +++
 .../webapp/public/resources/js/configeditor-settings-form.js   | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp b/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp
index 45509d765..ed6aaed7d 100644
--- a/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp
+++ b/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp
@@ -68,6 +68,9 @@
     <label class="checkboxWrapper">
         <input id="<%=loopConfiguration.getName()%>" name="<%=loopConfiguration.getName()%>" type="checkbox" <%=checked?"checked":""%> <pwm:autofocus/>/>
         <%=loopConfiguration.getLabel(formLocale)%>
+        <%if(loopConfiguration.isRequired()){%>
+        <span style="font-style: italic; font-size: smaller" id="label_required_<%=loopConfiguration.getName()%>">*&nbsp;</span>
+        <%}%>
     </label>
     <% } else { %>
     <label for="<%=loopConfiguration.getName()%>">
diff --git a/server/src/main/webapp/public/resources/js/configeditor-settings-form.js b/server/src/main/webapp/public/resources/js/configeditor-settings-form.js
index 6998964fc..1b8175c00 100644
--- a/server/src/main/webapp/public/resources/js/configeditor-settings-form.js
+++ b/server/src/main/webapp/public/resources/js/configeditor-settings-form.js
@@ -228,7 +228,7 @@ FormTableHandler.showOptionsDialog = function(keyName, iteration) {
     var currentValue = PWM_VAR['clientSettingCache'][keyName][iteration];
 
     var hideStandardOptions = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_HideStandardOptions');
-    var showRequired = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowRequiredOption') && (type !== 'checkbox');
+    var showRequired = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowRequiredOption');// && (type !== 'checkbox');
     var showUnique = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowUniqueOption');
     var showReadOnly = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowReadOnlyOption');
     var showMultiValue = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowMultiValueOption');

From 0bdfd355693991b4a29a18f8f5ff7ccf5471caba Mon Sep 17 00:00:00 2001
From: Marco R <xoot123@yahoo.it>
Date: Mon, 26 Mar 2018 09:50:48 +0200
Subject: [PATCH 3/5] Revert "Fix checkboxes sent value" on master

This reverts commit 07abb7eed67ee1c6ac36119312ed9eefe9e33ecf.
---
 server/src/main/webapp/public/resources/js/newuser.js | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/server/src/main/webapp/public/resources/js/newuser.js b/server/src/main/webapp/public/resources/js/newuser.js
index ed7d33be4..d24d486b8 100644
--- a/server/src/main/webapp/public/resources/js/newuser.js
+++ b/server/src/main/webapp/public/resources/js/newuser.js
@@ -48,14 +48,7 @@ PWM_NEWUSER.makeFormData=function() {
 
     for (var i = 0; i < newUserForm.elements.length; i++ ) {
         var loopElement = newUserForm.elements[i];
-        
-        if(loopElement.type == "checkbox") {
-        	if(loopElement.checked) {
-        		paramData[loopElement.name] = loopElement.value;
-        	}
-        } else {
-        	paramData[loopElement.name] = loopElement.value;
-        }
+        paramData[loopElement.name] = loopElement.value;
     }
 
     return paramData;

From 5321dfcbe8f42c56f46dda59d6e583c364ea5c0b Mon Sep 17 00:00:00 2001
From: Marco R <xoot123@yahoo.it>
Date: Mon, 26 Mar 2018 09:51:07 +0200
Subject: [PATCH 4/5] Revert "Let checkboxes be a required field" on master

This reverts commit f966083b50ab3eb7d4880c257ac2a5c8e7b6209e.
---
 server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp           | 3 ---
 .../webapp/public/resources/js/configeditor-settings-form.js   | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp b/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp
index ed6aaed7d..45509d765 100644
--- a/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp
+++ b/server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp
@@ -68,9 +68,6 @@
     <label class="checkboxWrapper">
         <input id="<%=loopConfiguration.getName()%>" name="<%=loopConfiguration.getName()%>" type="checkbox" <%=checked?"checked":""%> <pwm:autofocus/>/>
         <%=loopConfiguration.getLabel(formLocale)%>
-        <%if(loopConfiguration.isRequired()){%>
-        <span style="font-style: italic; font-size: smaller" id="label_required_<%=loopConfiguration.getName()%>">*&nbsp;</span>
-        <%}%>
     </label>
     <% } else { %>
     <label for="<%=loopConfiguration.getName()%>">
diff --git a/server/src/main/webapp/public/resources/js/configeditor-settings-form.js b/server/src/main/webapp/public/resources/js/configeditor-settings-form.js
index 1b8175c00..6998964fc 100644
--- a/server/src/main/webapp/public/resources/js/configeditor-settings-form.js
+++ b/server/src/main/webapp/public/resources/js/configeditor-settings-form.js
@@ -228,7 +228,7 @@ FormTableHandler.showOptionsDialog = function(keyName, iteration) {
     var currentValue = PWM_VAR['clientSettingCache'][keyName][iteration];
 
     var hideStandardOptions = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_HideStandardOptions');
-    var showRequired = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowRequiredOption');// && (type !== 'checkbox');
+    var showRequired = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowRequiredOption') && (type !== 'checkbox');
     var showUnique = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowUniqueOption');
     var showReadOnly = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowReadOnlyOption');
     var showMultiValue = PWM_MAIN.JSLibrary.arrayContains(settings['flags'],'Form_ShowMultiValueOption');

From 37d8eee13e1917a98a53b9b3bcdebd6e799e9042 Mon Sep 17 00:00:00 2001
From: Marco R <xoot123@yahoo.it>
Date: Mon, 26 Mar 2018 11:08:50 +0200
Subject: [PATCH 5/5] The user DN is sent along with form fields to the web
 service

---
 .../pwm/http/servlet/newuser/NewUserServlet.java    |  2 +-
 .../pwm/http/servlet/newuser/NewUserUtils.java      | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/server/src/main/java/password/pwm/http/servlet/newuser/NewUserServlet.java b/server/src/main/java/password/pwm/http/servlet/newuser/NewUserServlet.java
index 3f622c3b6..0e40f084f 100644
--- a/server/src/main/java/password/pwm/http/servlet/newuser/NewUserServlet.java
+++ b/server/src/main/java/password/pwm/http/servlet/newuser/NewUserServlet.java
@@ -420,7 +420,7 @@ static PasswordUtility.PasswordCheckInfo verifyForm(
                 validationFlags.toArray( new FormUtility.ValidationFlag[ validationFlags.size() ] )
         );
 
-        NewUserUtils.remoteVerifyFormData( pwmRequest, newUserForm );
+        NewUserUtils.remoteVerifyFormData( pwmRequest, newUserForm, null );
 
         final UserInfo uiBean = UserInfoBean.builder()
                 .cachedPasswordRuleAttributes( FormUtility.asStringMap( formValueData ) )
diff --git a/server/src/main/java/password/pwm/http/servlet/newuser/NewUserUtils.java b/server/src/main/java/password/pwm/http/servlet/newuser/NewUserUtils.java
index b6abc67f8..eb52dda81 100644
--- a/server/src/main/java/password/pwm/http/servlet/newuser/NewUserUtils.java
+++ b/server/src/main/java/password/pwm/http/servlet/newuser/NewUserUtils.java
@@ -301,7 +301,7 @@ static void createUser(
         NewUserUtils.LOGGER.trace( pwmSession, "new user ldap creation process complete, now authenticating user" );
 
         // write data to remote web service
-        remoteWriteFormData( pwmRequest, newUserForm );
+        remoteWriteFormData( pwmRequest, newUserForm, newUserDN );
 
         // authenticate the user to pwm
         final UserIdentity userIdentity = new UserIdentity( newUserDN, pwmApplication.getConfig().getDefaultLdapProfile().getIdentifier() );
@@ -529,7 +529,8 @@ static Map<String, String> figureDisplayableProfiles( final PwmRequest pwmReques
 
     static void remoteVerifyFormData(
             final PwmRequest pwmRequest,
-            final NewUserForm newUserForm
+            final NewUserForm newUserForm,
+            final String userDn
 
     )
             throws PwmUnrecoverableException, PwmDataValidationException
@@ -537,13 +538,15 @@ static void remoteVerifyFormData(
         remoteSendFormData(
                 pwmRequest,
                 newUserForm,
+                userDn,
                 FormDataRequestBean.Mode.verify
         );
     }
 
     static void remoteWriteFormData(
             final PwmRequest pwmRequest,
-            final NewUserForm newUserForm
+            final NewUserForm newUserForm,
+            final String userDn
 
     )
             throws PwmUnrecoverableException, PwmDataValidationException
@@ -551,6 +554,7 @@ static void remoteWriteFormData(
         remoteSendFormData(
                 pwmRequest,
                 newUserForm,
+                userDn,
                 FormDataRequestBean.Mode.write
         );
     }
@@ -558,6 +562,7 @@ static void remoteWriteFormData(
     private static void remoteSendFormData(
             final PwmRequest pwmRequest,
             final NewUserForm newUserForm,
+            final String userDn,
             final FormDataRequestBean.Mode mode
 
     )
@@ -583,9 +588,11 @@ private static void remoteSendFormData(
                 .formInfo( formInfo )
                 .formConfigurations( newUserProfile.readSettingAsForm( PwmSetting.NEWUSER_FORM ) )
                 .formValues( newUserForm.getFormData() )
+                .userDN( userDn )
                 .build();
 
         final FormDataResponseBean formDataResponseBean = restFormDataClient.invoke( formDataRequestBean, pwmRequest.getLocale() );
+
         if ( formDataResponseBean.isError() )
         {
             final ErrorInformation error = new ErrorInformation(