In my ASP.NET MVC (C#) project I must learn whether a user password is expired or not? I found some answers about that on the internet but they didn't be useful for me.
The first way to do using maxpwdage +pwdlastset= password expired date, and the second solution is that using useraccountcontrol attribute to learn whether it is expired or not. If this attribute's value is 8389120, user password is expired.
Altough user password is expired in AD, useraccountcontrolvalue is still 512. I tried to do with maxpwdage+pwdlastset but I couldn't see an attribute like maxpwdage (I got users as an administrator)
Active Directory user password expiration date .NET/OU Group Policy (first way) https://support.microsoft.com/en-us/kb/305144 (second way)
Both of them aren't working because of reasons that I mentioned above.
Are there any other ways to do this or how can i see value of the maxpwdage attribute?
EDIT: I am getting the user who i want from here
DirectoryEntry dEntry = new DirectoryEntry
( "LDAP://a.b.c:123/OU=d, DC=e, DC=f", this.GetAdUserName(),
this.GetAdUserPassword() );
DirectorySearcher directorySearcher = new DirectorySearcher( dEntry );
directorySearcher.Asynchronous = true;
directorySearcher.CacheResults = true;
directorySearcher.Filter = "(&(sAMaccountName=" + identificationNumber + "))";
SearchResult user = directorySearcher.FindOne();
return user;
I am checking user's properties but I couldn't find maxpwdage property.