问题描述
我负责的两个领域 - 一个是信任域。有可能是一个JohnSmith上一个域与另一个JohnSmith为另一方。这两种人需要登录到我的应用程序。
我的问题:没关系我通过在哪个域 - 这code返回true! 如何知道哪些JohnSmith是登录?
静态公共布尔CheckCredentials(
用户名字符串,字符串密码,串域)
{
使用(VAR上下文=新PrincipalContext(ContextType.Domain,域))
{
返回context.ValidateCredentials(用户名,密码);
}
}
在 ValidateCredentials
与的UserPrincipalName
的作品,你也许可以尝试建立的第一个参数(用户名)相结合的登录和创建用户名域 [email protected]
与 [email protected]
。
I'm dealing with two domains - one is a trusted domain. There may be a JohnSmith on one domain and another JohnSmith on the other. Both of these people need to log into my application.
My problem: it doesn't matter which domain I pass in - this code returns true! How do I know which JohnSmith is logging in?
static public bool CheckCredentials(
string userName, string password, string domain)
{
using (var context = new PrincipalContext(ContextType.Domain, domain))
{
return context.ValidateCredentials(userName, password);
}
}
The ValidateCredentials
works with userPrincipalName
you perhaps can try to build the first parameter (username) combining the login and the domain to create the username [email protected]
versus [email protected]
.
这篇关于活动目录域PrincipalContext.ValidateCredentials歧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!