NetUserEnum我想用这个函数获得Administrator域下的几个帐户,并不想获得本地计算机的所有帐号。对这个参数设置了都没什么做用。
FILTER_TEMP_DUPLICATE_ACCOUNT Enumerates local user account data on a domain controller. 
FILTER_NORMAL_ACCOUNT Enumerates global user account data on a computer. 
FILTER_INTERDOMAIN_TRUST_ACCOUNT Enumerates domain trust account data on a domain controller. The data is associated with the accounts of domains trusting the specified domain. 
FILTER_WORKSTATION_TRUST_ACCOUNT Enumerates workstation or member server account data on a domain controller. 
FILTER_SERVER_TRUST_ACCOUNT 请问大家我该怎么判断。谢谢!!!并且我该怎么获得帐号的密码!!!!

解决方案 »

  1.   

    获取域下面的所有账户
    LPUSER_INFO_0 pBuf = NULL;
    LPUSER_INFO_0 pTmpBuf;
    DWORD dwLevel = 0;
    DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
    DWORD dwEntriesRead = 0;
    DWORD dwTotalEntries = 0;
    DWORD dwResumeHandle = 0;
    DWORD i;
    DWORD dwTotalCount = 0;
    NET_API_STATUS nStatus;
    LPTSTR pszServerName = NULL; // The server is not the default local computer.
    //
    pszServerName = _T("\\\\HOLD");   // <<<<<<<<<<<<<<<<<<<< 域名, 必须以\\开头
    wprintf(L"\nUser account on %s: \n", pszServerName);
    //
    // Call the NetUserEnum function, specifying level 0; 
    //   enumerate global user account types only.
    //
    do // begin do
    {
    nStatus = NetUserEnum(pszServerName,
    dwLevel,
    FILTER_NORMAL_ACCOUNT, // global users
    (LPBYTE*)&pBuf,
    dwPrefMaxLen,
    &dwEntriesRead,
    &dwTotalEntries,
    &dwResumeHandle);
    //
    // If the call succeeds,
    //
    if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
    {
    if ((pTmpBuf = pBuf) != NULL)
    {
    //
    // Loop through the entries.
    //
    for (i = 0; (i < dwEntriesRead); i++)
    {
    assert(pTmpBuf != NULL); if (pTmpBuf == NULL)
    {
    fprintf(stderr, "An access violation has occurred\n");
    break;
    }
    //
    //  Print the name of the user account.
    //
    wprintf(L"\t-- %s\n", pTmpBuf->usri0_name);

    pTmpBuf++;
    dwTotalCount++;
    }
    }
    }
    //
    // Otherwise, print the system error.
    //
    else
    fprintf(stderr, "A system error has occurred: %d\n", nStatus);
    //
    // Free the allocated buffer.
    //
    if (pBuf != NULL)
    {
    NetApiBufferFree(pBuf);
    pBuf = NULL;
    }
    }
    // Continue to call NetUserEnum while 
    //  there are more entries. 
    // 
    while (nStatus == ERROR_MORE_DATA); // end do
    //
    // Check again for allocated memory.
    //
    if (pBuf != NULL)
    NetApiBufferFree(pBuf);
      

  2.   

     pszServerName = _T("\\\\HOLD");   // <<<<<<<<<<<<<<<<<<<< 域名, 必须以\\开头
    你这个参数就是这样设置的?
      

  3.   

    pszServerName = (LPWSTR)("\\\\HOLD");    莫非是以为我强制转换?
      

  4.   

    NetUserEnum 的第一个参数必须是 unicodeNetUserEnum(L"\\\\你的域名",
                dwLevel,
                FILTER_NORMAL_ACCOUNT, // global users
                (LPBYTE*)&pBuf,
                dwPrefMaxLen,
                &dwEntriesRead,
                &dwTotalEntries,
                &dwResumeHandle);
    你这样改一下试试