title: How to change password in ASP.NET using Directory LDAP
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
      CodeBehind="ChangePassword.aspx.cs" Inherits="FormsAuthAd.Account.ChangePassword" %&gt;
  &lt;%@ Import Namespace="FormsAuthAd" %&gt;
  
  &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;
      &lt;h2&gt;
          Change Password
      &lt;/h2&gt;
      &lt;p&gt;
          Use the form below to change your password.
      &lt;/p&gt;
      &lt;p&gt;
          New passwords are required to be a minimum of &lt;%= Membership.MinRequiredPasswordLength %&gt; characters in length.
      &lt;/p&gt;
      &lt;asp:ChangePassword ID="ChangeUserPassword" runat="server" CancelDestinationPageUrl="~/Default.aspx" EnableViewState="false" RenderOuterTable="false" 
           SuccessPageUrl="ChangePasswordSuccess.aspx"&gt;
          &lt;ChangePasswordTemplate&gt;
              &lt;span class="failureNotification"&gt;
                  &lt;asp:Literal ID="FailureText" runat="server"&gt;&lt;/asp:Literal&gt;
              &lt;/span&gt;
              &lt;asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification" 
                   ValidationGroup="ChangeUserPasswordValidationGroup"/&gt;
              &lt;div class="accountInfo"&gt;
                  &lt;fieldset class="changePassword"&gt;
                      &lt;legend&gt;Account Information&lt;/legend&gt;
                      &lt;p&gt;
                          &lt;asp:Label ID="CurrentPasswordLabel" runat="server" AssociatedControlID="CurrentPassword"&gt;Old Password:&lt;/asp:Label&gt;
                          &lt;asp:TextBox ID="CurrentPassword" runat="server" CssClass="passwordEntry" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
                          &lt;asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server" ControlToValidate="CurrentPassword" 
                               CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Old Password is required." 
                               ValidationGroup="ChangeUserPasswordValidationGroup"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                      &lt;/p&gt;
                      &lt;p&gt;
                          &lt;asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword"&gt;New Password:&lt;/asp:Label&gt;
                          &lt;asp:TextBox ID="NewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
                          &lt;asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" 
                               CssClass="failureNotification" ErrorMessage="New Password is required." ToolTip="New Password is required." 
                               ValidationGroup="ChangeUserPasswordValidationGroup"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                      &lt;/p&gt;
                      &lt;p&gt;
                          &lt;asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword"&gt;Confirm New Password:&lt;/asp:Label&gt;
                          &lt;asp:TextBox ID="ConfirmNewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
                          &lt;asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword" 
                               CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm New Password is required."
                               ToolTip="Confirm New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                          &lt;asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword" 
                               CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry."
                               ValidationGroup="ChangeUserPasswordValidationGroup"&gt;*&lt;/asp:CompareValidator&gt;
                      &lt;/p&gt;
                  &lt;/fieldset&gt;
                  &lt;p class="submitButton"&gt;
                      &lt;asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"/&gt;
                      &lt;asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword" Text="Change Password" 
                           ValidationGroup="ChangeUserPasswordValidationGroup" OnClick="ChangePassword"/&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
          &lt;/ChangePasswordTemplate&gt;
      &lt;/asp:ChangePassword&gt;
  &lt;/asp:Content&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>i want to change my password using my web app using ASP.NET
  but how to apply the new password to my ldap directory?
  i still confuse, what should i write code to connect my change password app to ldap directory.</p>
  
  <p>in logon form, i'm success to connected from my web app to ldap directory.
  but i confuse to sent my new password to ldap directory.
  can somebody help me, what should i do to complete this app?
  thanks before.</p>