問題描述
我正在處理兩個域 - 一個是受信任域.一個域上可能有一個 JohnSmith,另一個域上可能有另一個 JohnSmith.這兩個人都需要登錄我的應(yīng)用程序.
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.
我的問題:我傳入哪個域并不重要 - 此代碼返回 true!我如何知道哪個 JohnSmith 正在登錄?
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);
}
}
推薦答案
ValidateCredentials
與 userPrincipalName
一起使用,您也許可以嘗試構(gòu)建第一個參數(shù)(用戶名)登錄和域來創(chuàng)建用戶名 JohnSmith@dom1.com
與 JohnSmith@dom2.com
.
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
.
這篇關(guān)于Active Directory PrincipalContext.ValidateCredentials 域消歧的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!