【发布时间】:2016-02-16 12:09:00
【问题描述】:
在过去的几年里,我一直在使用这个小功能来验证用户凭据,没有任何问题。 createPrincipalContext 方法返回带有 ContextType.Machine 和机器名称的 PrincipalContext。
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: 系统找不到指定的文件。
除了机器更新之外,没有其他任何改变。过去几天我一直在网上搜索可能导致问题的原因。
在确定可能的原因以及可能的解决方案方面,有没有人有经验?
【问题讨论】:
-
只是说我有同样的问题,我目前正在调查。如果您找到解决方案,请添加更新
-
我已经用完了我所有的调试知识。该错误似乎发生在 IAds.GetInfo 中,但这是 COM 代码,因此没有可用的源代码。 Process Monitor 没有抛出任何线索,看起来没有任何访问文件的尝试。对我来说发生在两台机器上,我可能不得不回滚到以前的 Windows 10 版本
-
我放弃了尝试找出导致问题的原因,而是尝试了一种解决方法。当我遇到问题时,我正在使用 Web > 服务器下的 IIS Express 进行调试。我在机器上创建了一个本地站点并将服务器更改为 Local IIS 并将项目 URL 指向它。从那里我能够在没有得到 FileNotFoundException 的情况下进行调试。
-
很奇怪。我已经在使用本地 IIS,所以这不是我的问题。我会尝试重新创建 IIS 应用程序,看看是否能解决它
-
我相信是因为在 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.DirectoryServices.AccountManagement 更新后找不到dll .dll - 虽然不确定如何处理该线索..
标签: c# filenotfoundexception principalcontext