从密码策略中获取信息

Get information from Password Policy

本文关键字:获取 信息 策略 密码      更新时间:2023-10-16

是否有办法从密码策略中获取一些信息?如密码长度、密码最长使用时间等

我试着在注册表中查找,但没有找到我要找的。

您可以使用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:  %dn", pBuf->usrmod0_min_passwd_len);
          }
       }
       // Otherwise, print the system error.
       //
       else
          fprintf(stderr, "A system error has occurred: %dn", nStatus);
       //
       // Free the allocated memory.
       //
       if (pBuf != NULL)
          NetApiBufferFree(pBuf);
        return Age;
    }