在过去的几年里,我一直在使用这个小功能来验证用户凭据,没有任何问题。该createPrincipalContext
方法返回一个PrincipalContext
withContextType.Machine
和机器名称。
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 = UserPrincipal.FindByIdentity(principalContext, username)) {
return user.Enabled.GetValueOrDefault(false);
}
}
}
} catch (PrincipalOperationException e) {
traceError(e);
} catch (Exception e) {
traceError(e);
}
return false;
}
我的开发机器最近自动更新到最新版本的Windows 10,从那以后,principalContext.ValidateCredentials
一直抛出以下异常。
System.IO.FileNotFoundException:系统找不到指定的文件。
除了机器更新之外,没有其他任何改变。最近几天我一直在网上搜索可能导致问题的原因。
有没有人在确定可能是什么原因以及可能的解决方案方面有任何经验?