【问题标题】:System.DirectoryServices.AccountManagement bootstrapping myselfSystem.DirectoryServices.AccountManagement 引导自己
【发布时间】:2011-04-07 20:46:51
【问题描述】:

我正在尝试在 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 的前面,但连接失败。我被难住了。

谢谢,

卡尔-

【问题讨论】:

    标签: c# active-directory directoryservices


    【解决方案1】:

    尝试简化您的 PrincipalContext 行:

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

    这假设您的域是 XXXXXXX.org。您也可以尝试将您的域放在您的用户名前面:“XXXXXX.org\username”。

    【讨论】:

      猜你喜欢
      • 2017-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多