I’m using System.DirectoryServices.AccountManagement library to validate a local user.
I’ve got the following code:
private bool IsValidWindowsUser(string userName, string password)
{
using (var p = new PrincipalContext(ContextType.Machine))
return p.ValidateCredentials(userName, password);
}
But whenever I am passing correct username with ".\" preappend e.g if the user is name is "test" and if I am passing username like ".\test" then it is giving me an exception
The network path was not found.
Can somebody please help me. If I remove ".\" then it is working fine.
My another condition is I only want to validate Local machine user not domain user.
Please help