Ragaei Mahmoud Ragaei Mahmoud - 11 months ago 79
ASP.NET (C#) Question

how to get expiration date of local windows account?

I need to create C# method like this :

void deleteExpiredAccounts(String Account,dateTime expirationDate)
if(expirationDate == DateTime.Now)
DirectoryEntry localDirectory = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntries users = localDirectory.Children;
DirectoryEntry user = users.Find(Account);

any idea will be appreciated..thanks in advance!

Answer Source

Checkout maxPwdAge


Console.Writeline( user.Properties["maxPwdAge"].ToString());