[NET]
authorEric Kohl <eric.kohl@reactos.org>
Thu, 31 Mar 2016 21:48:43 +0000 (21:48 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Thu, 31 Mar 2016 21:48:43 +0000 (21:48 +0000)
Net utility not enumerating local user accounts.
Patch by Curtis Wilson.
CORE-11023 #resolve #comment Thanks a lot!

svn path=/trunk/; revision=71087

reactos/base/applications/network/net/cmdUser.c

index 7637ba9..7f97ea3 100644 (file)
@@ -5,6 +5,7 @@
  * PURPOSE:
  *
  * PROGRAMMERS:     Eric Kohl
+ *                  Curtis Wilson
  */
 
 #include "net.h"
@@ -45,31 +46,37 @@ EnumerateUsers(VOID)
 
     NetApiBufferFree(pServer);
 
-    Status = NetUserEnum(NULL,
-                         0,
-                         0,
-                         (LPBYTE*)&pBuffer,
-                         MAX_PREFERRED_LENGTH,
-                         &dwRead,
-                         &dwTotal,
-                         &ResumeHandle);
-    if (Status != NERR_Success)
-        return Status;
-
-    qsort(pBuffer,
-          dwRead,
-          sizeof(PUSER_INFO_0),
-          CompareInfo);
-
-//    printf("dwRead: %lu  dwTotal: %lu\n", dwRead, dwTotal);
-    for (i = 0; i < dwRead; i++)
+    do
     {
-//        printf("%p\n", pBuffer[i].lgrpi0_name);
-         if (pBuffer[i].usri0_name)
-            PrintToConsole(L"%s\n", pBuffer[i].usri0_name);
-    }
+        Status = NetUserEnum(NULL,
+                             0,
+                             0,
+                             (LPBYTE*)&pBuffer,
+                             MAX_PREFERRED_LENGTH,
+                             &dwRead,
+                             &dwTotal,
+                             &ResumeHandle);
+        if ((Status != NERR_Success) && (Status != ERROR_MORE_DATA))
+            return Status;
+
+        qsort(pBuffer,
+              dwRead,
+              sizeof(PUSER_INFO_0),
+              CompareInfo);
+
+        for (i = 0; i < dwRead; i++)
+        {
+            if (pBuffer[i].usri0_name)
+                PrintToConsole(L"%s\n", pBuffer[i].usri0_name);
+        }
 
-    NetApiBufferFree(pBuffer);
+        if (pBuffer != NULL)
+        {
+            NetApiBufferFree(pBuffer);
+            pBuffer = NULL;
+        }
+    }
+    while (Status == ERROR_MORE_DATA);
 
     return NERR_Success;
 }