PrincipalContext.ValidateCredentials始终返回false随着XP的机器ContextType

编程入门 行业动态 更新时间:2024-10-26 11:16:50
本文介绍了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

本文发布于:2023-11-17 05:16:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608958.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:机器   ValidateCredentials   PrincipalContext   false   ContextType

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!