我负责的两个领域 - 一个是信任域。有可能是一个JohnSmith上一个域与另一个JohnSmith为另一方。这两种人需要登录到我的应用程序。
我的问题:没关系我通过在哪个域 - 这code返回true! 如何知道哪些JohnSmith是登录?
静态公共布尔CheckCredentials( 用户名字符串,字符串密码,串域) { 使用(VAR上下文=新PrincipalContext(ContextType.Domain,域)) { 返回context.ValidateCredentials(用户名,密码); } }解决方案
在 ValidateCredentials 与的UserPrincipalName 的作品,你也许可以尝试建立的第一个参数(用户名)相结合的登录和创建用户名域 JohnSmith@dom1 与 JohnSmith@dom2 。
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 versus JohnSmith@dom2.
更多推荐
活动目录域PrincipalContext.ValidateCredentials歧
发布评论