principalcontext

System.DirectoryServices.AccountManagement.PrincipalContext broken after Windows 10 update

北慕城南 提交于 2019-11-28 05:46:30
I've been using this little function without any issue for the past few years to validate user credentials. The createPrincipalContext method returns a PrincipalContext with ContextType.Machine and the machine name. public static bool ValidateCredentials(string username, string password, string domain = null) { try { using (var principalContext = createPrincipalContext(username, domain)) { username = GetLoginInfo(username).Username; // validate the credentials if (principalContext.ValidateCredentials(username, password)) { //once valid check if account is enabled using (UserPrincipal user =