簡體   English   中英

System.DirectoryServices.AccountManagement自我引導

[英]System.DirectoryServices.AccountManagement bootstrapping myself

我正在嘗試在System.DirectoryServices.AccountManagement命名空間上進行自我引導,以解決我遇到的另一個問題。 在網絡中,我想在廣告中切換“ ChangePasswordOnNextLogon”標志,並且此命名空間使其看起來很容易。

因此,我嘗試使用與使用AdMembershipProvider登錄時所使用的用戶名和密碼相同的用戶名和密碼。

PrincipalContext oPrincipalContext = 
   new PrincipalContext(ContextType.Domain, "10.1.XXX.XXX", "DC=XXXXXXXX,DC=ORG",
                        ContextOptions.SimpleBind, AUserThatWorks, APasswordThatWorks);

UserPrincipal oUserPrincipal = 
    UserPrincipal.FindByIdentity(oPrincipalContext, AdUserName);

// we need to see if they can authenticate before changing password,so we have to turn this off manually. - EWB
oUserPrincipal.RefreshExpiredPassword();

bool b = oPrincipalContext.ValidateCredentials( AdUserName, AdPassword );

if (!b)
   oUserPrincipal.ExpirePasswordNow();

return b;

但是,當它到達FindByIdentity時,出現“用戶名或密碼錯誤”錯誤。

由於用戶在其他地方工作,因此我認為它必須是獲取主體上下文的其他參數之一。 有人給我提示嗎? 我嘗試將LDAP放在URL的前面,但是后來無法連接。 我很沮喪

謝謝,

Cal-

嘗試簡化PrincipalContext行:

PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Domain, "XXXXXX.org", AUserThatWorks, PasswordThatWorks);

假設您的域是XXXXXXX.org。 您也可以嘗試將域名放在用戶名“ XXXXXX.org \\ username”的前面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM