0
我试图在System.DirectoryServices.AccountManagement
名称空间上引导自己以解决我遇到的另一个问题。在网络中,我想切换广告中的“ChangePasswordOnNextLogon”标志,这个命名空间使它看起来很容易。System.DirectoryServices.AccountManagement引导我自己
所以我尝试使用它与我使用登录使用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
我得到一个“坏的用户名或密码”的错误。
由于用户在其他地方工作,我认为它必须是获取主要背景的其他参数之一。任何人对我有任何提示?我尝试将URL放在URL的正面,但未能连接。我很难过。
感谢,
校准 -