4.2 NetrWkstaUserEnum Example
In this example, the client calls the NetrWkstaUserEnum method (section 3.2.4.3) to enumerate the names of currently logged-on users on a server named "SrvrA". Five active users are logged onto server "SrvrA".
The client calls NetrWkstaUserEnum with ServerName equal to "SrvrA" and the Level field of the WKSTA_USER_ENUM_STRUCT structure (section 2.2.5.14) passed in the UserInfo parameter set to 0x00000000. The client also sets the PreferredMaximumLength parameter to 0x00000100 and passes a non-NULL pointer in parameters TotalEntries and ResumeHandle.
Only the names of the first two logged-on users fit into 0x00000100 bytes. On receiving this method, the server executes the method locally and returns ERROR_MORE_DATA. The server returns the names of the first two logged-on users in the UserInfo parameter. It also sets the value of TotalEntries to 0x00000005 and ResumeHandle to 0x00000120. The value of ResumeHandle is implementation-specific.
To continue enumerating the names of logged-on users, the client calls NetrWkstaUserEnum with ServerName equal to "SrvrA", and the Level field of the WKSTA_USER_ENUM_STRUCT structure passed in the UserInfo parameter set to 0x00000000. The client also sets the PreferredMaximumLength parameter to MAX_PREFERRED_LENGTH (section 2.2.1.3) and passes a non-NULL pointer as TotalEntries. The client also passes the unchanged value of ResumeHandle (0x000000120).
On receiving this method, the server executes the method locally to continue enumeration based on a ResumeHandle value of 0x00000120, and returns NERR_Success. The server returns the names of the next three logged-on users in the UserInfo parameter. It also sets the value of TotalEntries to 0x00000005. The value of ResumeHandle is irrelevant.