Click here to Skip to main content
15,844,155 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have the requirement like below.

I want to get maxPwdAge value for specific Organization Unit or Group wise.Anybody help me how to do it.

I am able to get domain level maxPwdAge like below
 long maxPwdAge=0;
string domain="LDAP://,DC=test,DC=com";
string adsiUserName="test";
string adsiPassword="test";
 DirectoryEntry entry = new DirectoryEntry(domain, adsiUserName, adsiPassword,                 AuthenticationTypes.Secure);
       DirectorySearcher mySearcher = new DirectorySearcher(entry);
       string filter = "(maxPwdAge=*)"; //"maxPwdAge=*";
       mySearcher.Filter = filter;
       SearchResult results = mySearcher.FindOne();
       if (results != null)
           Int64 pwdAge = (Int64)results.Properties["maxPwdAge"][0];
           maxPwdAge = pwdAge / -864000000000;

How to get maxPwdAge for OU or group.

Thanks in advance.
Updated 19-Dec-14 8:24am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900