活动目录域PrincipalContext.ValidateCredentials歧 [英] Active Directory PrincipalContext.ValidateCredentials domain disambiguation

查看:124
本文介绍了活动目录域PrincipalContext.ValidateCredentials歧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我负责的两个领域 - 一个是信任域。有可能是一个JohnSmith上一个域与另一个JohnSmith为另一方。这两种人需要登录到我的应用程序。

我的问题:没关系我通过在哪个域 - 这code返回true! 如何知道哪些JohnSmith是登录?

 静态公共布尔CheckCredentials(
        用户名字符串,字符串密码,串域)
    {
        使用(VAR上下文=新PrincipalContext(ContextType.Domain,域))
        {
            返回context.ValidateCredentials(用户名,密码);
        }
    }
 

解决方案

ValidateCredentials 的UserPrincipalName 的作品,你也许可以尝试建立的第一个参数(用户名)相结合的登录和创建用户名域 JohnSmith@dom1.com JohnSmith@dom2.com

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 JohnSmith@dom1.com versus JohnSmith@dom2.com.

这篇关于活动目录域PrincipalContext.ValidateCredentials歧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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