Smart Device Functions:
Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than netapi32, prefix the name with the module name and a period.
Public Declare Function NetUserEnum Lib "Netapi32.dll" ( _
// Passing -1 as prefmaxlen makes the system allocate the buffer.
const int MAX_PREFERRED_LENGTH = -1;
// You'll need these for the return values
const int NERR_Success = 0; /* Success */
const int NERR_BASE = 2100;
const int NERR_InvalidComputer = (NERR_BASE+251); /* This computer name is invalid. */
const int ERROR_ACCESS_DENIED = 5;
const int ERROR_MORE_DATA = 234;
// Passing this for 'filter'
const int FILTER_TEMP_DUPLICATE_ACCOUNT = 0x0001;
const int FILTER_NORMAL_ACCOUNT = 0x0002;
const int FILTER_INTERDOMAIN_TRUST_ACCOUNT = 0x0008;
const int FILTER_WORKSTATION_TRUST_ACCOUNT = 0x0010;
const int FILTER_SERVER_TRUST_ACCOUNT = 0x0020;
[2005-06-15] VB sample contributed by Graeme Grant
[2006-03-09] VB sample fixed by Jaime Smith (can't cast Int32 to IntPtr, users and Users cannot both be used in the same scope in VB)
[2009-05-20] C# sample fixed by IEBasara
Tips & Tricks:
Please add some!
Dim _users As New ArrayList
NetUserEnum(server, 0, 2, bufPtr, -1, EntriesRead, TotalEntries, [Resume])
ArrayList users = new ArrayList();
Alternative Managed API:
Do you know one? Please contribute it!
using System.DirectoryServices; //System.DirectoryServices
DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://" + Environment.MachineName);
The NetUserEnum function provides information about all user accounts on a server.
4/30/2015 3:40:58 PM - -188.8.131.52
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.
1/13/2008 11:00:13 AM - tsahi-184.108.40.206
Please edit this page!
Do you have...