我用PrinciaplContext.ValidateCredentials验证了一套针对本地计算机凭据:
I'm using PrinciaplContext.ValidateCredentials to validate a set of credentials against the local machine:
string account = Context.ReadLine(); string pass = Context.ReadLine(); using (var context = new PrincipalContext(ContextType.Machine)) { bool valid = context.ValidateCredentials(account, pass); Console.WriteLine("valid: " + (valid ? "true" : "false")); }
控制台应用程序正在执行作为管理员,我试图验证管理员帐户/密码。该机运行的是Windows XP并且不是域的一部分。
The console application is executing as Administrator and I'm trying to validate the administrator account/password. The machine is running Windows XP and is not part of a domain.
运行不同Windows XP的机器,是一个域的一部分,在相同的code总是返回的密码是正确或不正确的事实。如果我使用ContextType.Domain指定帐户正确验证域。
Running the same code on a different Windows XP machine that is part of a domain always returns true regardless of the password being correct or incorrect. If I use ContextType.Domain specifying the domain the account correctly validates.
难道ValidateCredentials只是不反对XP的计算机环境中工作?有没有别的东西错了,我不占位置?
Does ValidateCredentials just not work in Machine context against XP? Is there something else wrong I'm not accounting for here?
推荐答案在 PrincipalContext 类是部分的的DirectoryServices 命名空间。它会站在有理由相信,没有一个领域,没有目录。因此,呼叫来验证一个目录将失败,如果XP的机器不是一个域的成员。
The PrincipalContext class is part of the DirectoryServices namespace. It would stand to reason that without a domain, there is no directory. Therefore the call to authenticate against a directory will fail if the XP machine is not a member of a domain.
更多推荐
PrincipalContext.ValidateCredentials始终返回false随着XP的机器ContextType
发布评论