zoukankan      html  css  js  c++  java
  • 枚举NT系统用户

    #define UNICODE
    #include <windows.h>
    #include <stdio.h>
    #include <lm.h>

    void main( int argc, char *argv[ ] )
    {
       PNET_DISPLAY_USER pBuff, p;
       DWORD res, dwRec, i = 0;
       //
       // You can pass a NULL or empty string
       //  to retrieve the local information.
       //
       TCHAR szServer[255]=TEXT("");

       if(argc > 1)
          //
          // Check to see if a server name was passed;
          //  if so, convert it to Unicode.
          //
          MultiByteToWideChar(CP_ACP, 0, argv[1], -1, szServer, 255);

       do // begin do
       {
          //
          // Call the NetQueryDisplayInformation function;
          //   specify information level 1 (user account information).
          //
          res = NetQueryDisplayInformation(szServer, 1, i, 1000, MAX_PREFERRED_LENGTH, &dwRec, (void**)&pBuff);
          //
          // If the call succeeds,
          //
          if((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA))
          {
             p = pBuff;
             for(;dwRec>0;dwRec--)
             {
                //
                // Print the retrieved group information.
                //
                printf("Name:      %S\n"
                      "Comment:   %S\n"
                      "Group ID:  %u\n"
                      "Attributes: %u\n"
                      "--------------------------------\n",
                      p->usri1_name,
                      p->usri1_comment,
                      p->usri1_user_id,
                      p->usri1_flags);
                //
                // If there is more data, set the index.
                //
                i = p->usri1_next_index;
                p++;
             }
             //
             // Free the allocated memory.
             //
             NetApiBufferFree(pBuff);
          }
          else
             printf("Error: %u\n", res);
       //
       // Continue while there is more data.
       //
       } while (res==ERROR_MORE_DATA); // end do
       return;
    }

  • 相关阅读:
    利用NPOI导出数据到Execl
    分享微信开发Html5轻游戏中的几个坑
    Integrate non-OSGi Dependencies
    Websocket Component
    ServiceMix in daemon mode
    springboot jwt配置(更新中)
    npm run build 后的dist文件,发布到web服务。
    不重复随机数列的生成算法 Leetcode 384. Shuffle an Array
    LSM树-HBASE为什么快
    混沌工程初探
  • 原文地址:https://www.cnblogs.com/MaxWoods/p/319095.html
Copyright © 2011-2022 走看看