Ragaei Mahmoud Ragaei Mahmoud - 2 months ago 23
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);
users.Remove(user);
}
}


any idea will be appreciated..thanks in advance!

Answer

Checkout maxPwdAge

Try

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