22.214.171.124 NetrWkstaUserEnum (Opnum 2)
The NetrWkstaUserEnum method returns information about users who are currently active on a remote computer.
unsigned long NetrWkstaUserEnum( [in, string, unique] WKSSVC_IDENTIFY_HANDLE ServerName, [in, out] LPWKSTA_USER_ENUM_STRUCT UserInfo, [in] unsigned long PreferredMaximumLength, [out] unsigned long* TotalEntries, [in, out, unique] unsigned long* ResumeHandle );
ServerName: A WKSSVC_IDENTIFY_HANDLE (section 126.96.36.199) that identifies the server. The client MUST map this structure to an RPC binding handle ([C706] sections 4.3.5 and 188.8.131.52). The server MUST ignore this parameter.
UserInfo: A pointer to the buffer to receive the data. The data MUST be returned as a WKSTA_USER_ENUM_STRUCT (section 184.108.40.206) structure that contains a Level member that specifies the type of structure to return.
PreferredMaximumLength: The number of bytes to allocate for the return data.
TotalEntries: The total number of entries that could have been enumerated if the buffer were big enough to hold all the entries.
ResumeHandle: A pointer that, if specified, and if this method returns ERROR_MORE_DATA, MUST receive an implementation-specific value<33> that can be passed in subsequent calls to this method, to continue with the enumeration of currently logged-on users.
If this parameter is NULL or points to zero, then the enumeration MUST start from the beginning of the list of currently logged-on users.
Return Values: When the message processing result matches the description in column two of the following table, this method MUST return one of the following values ([MS-ERREF] section 2.2). The most common error codes are listed in the following table.
The operation completed successfully.
Access is denied.
The information level is invalid.
More entries are available. The UserInfo buffer was not large enough to contain all the entries.
Any other return value MUST conform to the error code requirements specified in Protocol Details (section 3).
The server SHOULD<34> enforce security measures to verify that the caller has the required permissions to execute this routine. If the server enforces security measures, and the caller does not have the required credentials, then the server MUST fail the call with ERROR_ACCESS_DENIED. Specifications for determining the identity of the caller for the purpose of performing an access check are in [MS-RPCE] section 220.127.116.11.3.
If the Level member of the WKSTA_USER_ENUM_STRUCT structure passed in the UserInfo parameter does not equal 0x00000000 or 0x00000001, then the server MUST fail the call.
If the Level member equals 0x00000000, then the server MUST return an array of the names of users currently logged on the computer. The server MUST return this information by filling the WKSTA_USER_INFO_0_CONTAINER (section 18.104.22.168) in the WkstaUserInfo field of the UserInfo parameter.
If the Level member equals 0x00000001, then the server MUST return an array of the names and domain information of each user currently logged on the computer, and a list of OtherDomains (section 22.214.171.124) in the computer.
If the PreferredMaximumLength parameter equals MAX_PREFERRED_LENGTH (section 126.96.36.199), the server MUST return all the requested data. Otherwise, if the PreferredMaximumLength is insufficient to hold all the entries, then the server MUST return the maximum number of entries that fit in the UserInfo buffer and return ERROR_MORE_DATA.
The following rules specify processing of the ResumeHandle parameter:
If the ResumeHandle parameter is either NULL or points to 0x00000000, then the enumeration MUST start from the beginning of the list of the currently logged on users.<35>
If the ResumeHandle parameter points to a non-zero value, then the server MUST continue enumeration based on the value of ResumeHandle. The server is not required to maintain any state between calls to the NetrWkstaUserEnum method.
If the client specifies a ResumeHandle, and if the server returns ERROR_MORE_DATA, then the server MUST set the value to which ResumeHandle points to an implementation-specific value that allow the server to continue with this enumeration on a subsequent call to this method, with the same value for ResumeHandle.
The server is not required to maintain any state between calls to the NetrWkstaUserEnum method. If the server returns NERR_Success or ERROR_MORE_DATA, then it MUST set the TotalEntries parameter to equal the total number of entries that could have been enumerated from the current resume position.