I must recognize notebooks whose domain accounts
are no longer valid.
Invalid domain accounts may happen due to several problems. Mostly the client got restored from a backup and afterwards the domain account is not valid any more
Int this case the behavour is:
cached credentials
has access to shares
and files on the server (NTLM) Kerberos does not work
Is there any possibility to check the validity of the computer account?
With this code I can find invalid computer domain accounts
:
try
{
string sMyComputer = "MyComputer"
Domain computerDomain = Domain.GetComputerDomain(); // may! throw ActiveDirectoryObjectNotFoundException if computer account is invalid
string sComputerDomain = computerDomain.Name;
NTAccount acc_machine = new NTAccount(sComputerDomain, sMyComputer + "$");
SecurityIdentifier sid = (SecurityIdentifier)acc_machine.Translate(typeof(SecurityIdentifier)); // always throws an SystemException if computer account is invalid
}
catch
{
// something is wrong with the account
}
EDIT:
corrected error in code