有没有办法从密码策略中获取一些信息?如密码长度、密码最长使用期限等。
我尝试在注册表中查找,但没有找到我要查找的内容。
您可以使用NetUserModalsGet
. 这是获取 MaximumPasswordAge 的示例
int GetMaximumPasswordAge()
{
int Age = -1;
DWORD dwLevel = 0;
USER_MODALS_INFO_0 *pBuf = NULL;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
//
nStatus = NetUserModalsGet((LPCWSTR) pszServerName,
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds, print the global information.
//
if (nStatus == NERR_Success)
{
if (pBuf != NULL)
{
Age = pBuf->usrmod0_max_passwd_age/86400;
printf("\tMinimum password length: %d\n", pBuf->usrmod0_min_passwd_len);
}
}
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return Age;
}