【问题标题】:Retrieving specific data from Active Directory via LDAP in C++ (getting lockout threshold)在 C++ 中通过 LDAP 从 Active Directory 中检索特定数据(获取锁定阈值)
【发布时间】:2020-01-23 22:23:47
【问题描述】:

我正在改进一些代码,以帮助测试是否正确监控密码喷射。 这是注入的DLL的源代码: https://github.com/outflanknl/Spray-AD/blob/master/Src/Spray-AD/Spray-AD/ReflectiveDll.cpp

此 DLL 中的当前问题是它可能会锁定用户(因为某些用户的用户名可能已经有一些 badPwdCount),所以我需要正确检查用户当前的 badPwdCount 是什么以及 thresholdLockout 是什么每个用户在尝试作为特定用户进行身份验证之前(因为不同的用户可能有不同的密码策略)。

幸运的是,badPwdCount 并不难实现,我已经正确修改了 LDAP 过滤器:

WCHAR* pszPropertyList[3] = { L"sAMAccountName" , L"badPwdCount" , L"lockoutThreshold"};

并正确配置了 ExecuteSearch 功能:

else
{
    // Return specified properties
    hr = pContainerToSearch->ExecuteSearch(pszSearchFilter,
        pszPropertyList,
        3,
        &hSearch);
}

还有开关盒,它会正确捕获 badPwdCount:

case ADSTYPE_INTEGER:
for (x = 0; x < col.dwNumValues; x++) {
    if (_wcsicmp(col.pszAttrName, L"badPwdCount") == 0) {
        if (col.pADsValues->Integer >= 4 || col.pADsValues->Integer == 0) {  
            /*some code*/
            break;
        }
    }
}

但由于我想将 badPwdCount 与特定用户的锁定阈值(而不是上面示例中的 4)进行比较,因此我尝试提取 lockoutThreshold 属性,如下所示: https://docs.microsoft.com/en-us/windows/win32/adschema/a-lockoutthreshold

虽然我似乎无法获得阈值锁定的任何结果.. 代码甚至没有返回未知类型错误:

default:
     wprintf(L"[!] Unknown type %d.\n", col.dwADsType);

这对我来说很奇怪,因为我可以毫无问题地检索其他属性(例如 badPasswordTime)。

如何正确检索 lockoutThreshold?代码示例会很棒。

【问题讨论】:

标签: c++ dll active-directory ldap dll-injection


【解决方案1】:

在您链接到的documentation for lockoutThreshold 中,查看“使用的类”,其中列出了:

  • 域策略
  • 山姆域
  • Sam-Domain-Base

请注意,它不包括“用户”。

您不会在用户帐户上找到此属性。您将在域的根节点上找到它。

但是,正如您所发现的,lockoutThreshold 可以被细粒度的密码策略覆盖。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多