Ragaei Mahmoud Ragaei Mahmoud - 1 year ago 130
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());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download