PrincipalContext.ValidateCredentials始终返回false随着XP的机器ContextType [英] PrincipalContext.ValidateCredentials Always Returns False With Machine ContextType on XP

查看:164
本文介绍了PrincipalContext.ValidateCredentials始终返回false随着XP的机器ContextType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆