有没有办法从密码政策中获取一些信息?像密码长度,最大密码年龄等
我尝试在注册表中查找但未找到我要找的内容。
答案 0 :(得分:3)
您可以使用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;
}