Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let me start with <a href="http://support.microsoft.com/kb/323750" rel="noreferrer">http://support.microsoft.com/kb/323750</a> which contains Visual Basic and VBScript examples and <a href="http://www.anitkb.com/2010/03/how-to-implement-active-directory.html" rel="noreferrer">http://www.anitkb.com/2010/03/how-to-implement-active-directory.html</a> which outlines how the maxPwdAge OU setting impacts computers, not users. It also has a comment pointing to <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyId=7AF2E69C-91F3-4E63-8629-B999ADDE0B9E&amp;displaylang=en" rel="noreferrer">AloInfo.exe</a> as a tool from MS that can be used to get password ages.</p> <p>Here is the example:</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.DirectoryServices; namespace LDAP { class Program { static void Main(string[] args) { string domainAndUsername = string.Empty; string domain = string.Empty; string userName = string.Empty; string passWord = string.Empty; AuthenticationTypes at = AuthenticationTypes.Anonymous; StringBuilder sb = new StringBuilder(); domain = @"LDAP://w.x.y.z"; domainAndUsername = @"LDAP://w.x.y.z/cn=Lawrence E."+ " Smithmier\, Jr.,cn=Users,dc=corp,"+ "dc=productiveedge,dc=com"; userName = "Administrator"; passWord = "xxxpasswordxxx"; at = AuthenticationTypes.Secure; DirectoryEntry entry = new DirectoryEntry( domain, userName, passWord, at); DirectorySearcher mySearcher = new DirectorySearcher(entry); SearchResultCollection results; string filter = "maxPwdAge=*"; mySearcher.Filter = filter; results = mySearcher.FindAll(); long maxDays = 0; if(results.Count&gt;=1) { Int64 maxPwdAge=(Int64)results[0].Properties["maxPwdAge"][0]; maxDays = maxPwdAge/-864000000000; } DirectoryEntry entryUser = new DirectoryEntry( domainAndUsername, userName, passWord, at); mySearcher = new DirectorySearcher(entryUser); results = mySearcher.FindAll(); long daysLeft=0; if (results.Count &gt;= 1) { var lastChanged = results[0].Properties["pwdLastSet"][0]; daysLeft = maxDays - DateTime.Today.Subtract( DateTime.FromFileTime((long)lastChanged)).Days; } Console.WriteLine( String.Format("You must change your password within"+ " {0} days" , daysLeft)); Console.ReadLine(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload