0
Answer

How to get maxPwdAge by OrganizationUnit or Group wise in AD

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://10.10.1.100/OU=Dev,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;
}