Answered by:
CreateUserWizard control without password field

Question
-
User-1496162749 posted
I'm creating an asp.net web form (v4.5) to allow users to self-create their accounts in AD with their smart cards. When the user goes to the form, s/he must select his client certificate and provide his PIN. Then the app extracts the user data off the certificate and populates the form fields for verification. To implement this, I'm using the AD membership provider with the CreateUserWizard control. So far, all good except one thing:
Since the password is not required for creating the account (remember, users won't login with their usernames/passwords but with their smart cards), the password field must not be present on the form. However, when I remove it from the form, asp.net gives an error saying that it is required. Is there a way to bypass the password field?
Friday, August 26, 2016 9:12 AM
Answers
-
User-1496162749 posted
Cathy, when you say "it works fine in your application", are you able to create the account in AD simply by hiding the password field from the UI with CSS? I'm pretty sure you'll get an error as asp.net doesn't seem to process the request without the password input.
The two URLs you provided don't address my question.
Looks like AD is not designed to create a user account without a password as it cannot be done even through the AD Windows interface...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, August 31, 2016 11:32 AM
All replies
-
User-707554951 posted
Hi isunshine,
From your description, I suggest you could customize the contents of the CreateUserWizard control using the CreateUserWizardStep templates. To customize the user account creation step, create a <ContentTemplate> element within the <asp:CreateUserWizardStep> element. Inside the template, add markup and controls to define the layout and content of the UI for gathering the user information you need. Then you could hide the field you don’t need.
The following code may help you:<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"> <WizardSteps> <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"> <ContentTemplate> <table border="0" style="font-size: 100%; font-family: Verdana"> <tr> <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d"> Sign Up for Your New Account</td> </tr> <tr> <td align="right"> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"> User Name:</asp:Label></td> <td> <asp:TextBox ID="UserName" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td align="right" style="display:none"> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"> Password:</asp:Label></td> <td style="display:none"> <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td align="right" style="display:none"> <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword"> Confirm Password:</asp:Label></td> <td style="display:none"> <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword" ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td align="right"> <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email"> E-mail:</asp:Label></td> <td> <asp:TextBox ID="Email" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td align="right"> <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question"> Security Question:</asp:Label></td> <td> <asp:TextBox ID="Question" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="QuestionRequired" runat="server" ControlToValidate="Question" ErrorMessage="Security question is required." ToolTip="Security question is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td align="right"> <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer"> Security Answer:</asp:Label></td> <td> <asp:TextBox ID="Answer" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" ControlToValidate="Answer" ErrorMessage="Security answer is required." ToolTip="Security answer is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator> </td> </tr> <tr> <td align="center" colspan="2"> <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="CreateUserWizard1"></asp:CompareValidator> </td> </tr> <tr> <td align="center" colspan="2" style="color: red"> <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal> </td> </tr> </table> <asp:CheckBox ID="SubscribeCheckBox" runat="server" Checked="True" Text="Send me a monthly newsletter." /> <br /> <asp:CheckBox ID="ShareInfoCheckBox" runat="server" Checked="True" Text="Share my information with partner sites." /> </ContentTemplate> </asp:CreateUserWizardStep> <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server"> </asp:CompleteWizardStep> </WizardSteps> </asp:CreateUserWizard>
The output screenshots like below:
Hope this can help you. If you have any question and confusion about the problem. Please don't hesitate to let me know.
Best regards
CathyMonday, August 29, 2016 12:44 PM -
User-1496162749 posted
Hi Cathy,
Looks like you're just hiding the password fields on the client-side. I don't think it will do any good. Asp.net seems to require the password value to create the account.
Any other ideas anyone?Monday, August 29, 2016 2:57 PM -
User-1496162749 posted
Cathy, I tested your suggestion and found that asp.net gives an error saying that the password is required. Like I said before, your suggestion just hides the password textbox from the UI and asp.net cannot process the request without the password. Any other idea?
Tuesday, August 30, 2016 2:09 PM -
User-707554951 posted
Hi isunshine,
It works fine in my application. So,I suggest you could try to copy all code to your.aspx page in your application., if you don’t want hides the password textbox from the UI, you could refer to the following links. It may help you.
https://msdn.microsoft.com/en-us/library/ms178342%28v=vs.80%29.aspx?f=255&MSPPError=-2147217396
http://forums.asp.net/t/1304780.aspx?Remove+email+field+from+createUserWizard
Hope this can help you. If you have any question and confusion about the problem. Please don't hesitate to let me know.
Best regards
CathyWednesday, August 31, 2016 11:01 AM -
User-1496162749 posted
Cathy, when you say "it works fine in your application", are you able to create the account in AD simply by hiding the password field from the UI with CSS? I'm pretty sure you'll get an error as asp.net doesn't seem to process the request without the password input.
The two URLs you provided don't address my question.
Looks like AD is not designed to create a user account without a password as it cannot be done even through the AD Windows interface...
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, August 31, 2016 11:32 AM