title: Active Directory Password Expiration Date
body: <p>This is somewhat connected to this post, which I didn't want to pollute.</p>
  
  <p><a href="https://stackoverflow.com/questions/3764327/active-directory-user-password-expiration-date-net-ou-group-policy">Active Directory user password expiration date .NET/OU Group Policy</a></p>
  
  <p>Like the OP in that thread, I'm trying to get the password expiration date of a given AD UserName via code; however the attribute maxPwdAge referred in the thread above is not available when I tried to get all the available properties like this: </p>
  
  <pre><code>            PropertyCollection fields = myLDAP.Properties;
  
              foreach (String ldapField in fields.PropertyNames)
              {
                  // cycle through objects in each field e.g. group membership  
                  // (for many fields there will only be one object such as name)  
  
                  foreach (Object myCollection in fields[ldapField])
                      Console.WriteLine(String.Format("{0,-20} : {1}",
                                    ldapField, myCollection.ToString()));
              }
  </code></pre>
  
  <p>Even Microsoft's ADExplorer didn't show a password expiration date.</p>
  
  <p>But when I try this command prompt command:</p>
  
  <pre><code>net user thatuser /DOMAIN
  </code></pre>
  
  <p>it displays Password Expiration Date.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li>Why don't I see maxPwdAge as an attribute </li>
  <li>Where does the net user command get the Password Expiration Date from and how can I obtain it in C# code? </li>
  </ol>
  
  <p>Right now I'm testing this with a Console Application; while testing this, it was discovered that there isn't .Net 4.0 installed on the target machine, so I'm stuck with .Net 3.5</p>
  
  <p>I'm not a server admin, so I don't know the configuration details of the server. I'm new to this AD LDAP, so please help. Thank you. </p>