【问题标题】:How can I enable or disable an AD user account with an LDAP request?如何通过 LDAP 请求启用或禁用 AD 用户帐户?
【发布时间】:2012-04-07 09:20:34
【问题描述】:

到目前为止,我能够在 LDAP 中找到用户,但我不知道如何启用或禁用它们。

第二个问题,如果我的帐户具有域管理员权限,我是否能够从 LDAP 启用或禁用帐户?

注意:这是关于在 Windows 2003 上运行的 Microsoft Active Directory。

我知道我可以通过以下方式检查活跃使用

(!(useraccountcontrol:1.2.840.113556.1.4.803:=2))

禁用使用:

(useraccountcontrol:1.2.840.113556.1.4.803:=2)

问题是如何设置属性,使其不会丢失内部的其他二进制标志。

【问题讨论】:

    标签: active-directory ldap ldap-query


    【解决方案1】:

    您需要在这里使用一些逻辑。因此,要禁用用户,请设置禁用位 (2)。所以:

    const long ADS_UF_ACCOUNTDISABLE = 0x00000002;
    long userAccountControl = //currentUacValue
    long newUserAccountControl = (userAccountControl | ADS_UF_ACCOUNTDISABLE);
    

    要启用一个帐户,我们需要清除禁用位:

    long userAccountControl = //currentUacValue
    long newUserAccountControl = (userAccountControl & ~ADS_UF_ACCOUNTDISABLE)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-20
      相关资源
      最近更新 更多