NetLocalGroupGetMembers returns different members number according to LOCALGROUP_MEMBERS_INFO value
Question: I'd like to retrieve the number of users belonging to some Windows UserGroup.
From the documentation of the Python API :

    
    
    win32net.NetLocalGroupGetMembers(server, group, *level*) 
    

I understand that according to the _level_ param, I'll get differently
detailed data, corresponding to Windows LOCALGROUP_MEMBERS_INFO_0,
LOCALGROUP_MEMBERS_INFO_1, LOCALGROUP_MEMBERS_INFO_2 or
LOCALGROUP_MEMBERS_INFO_3 structures.

Thus, if 93 users belong to the specified userGroup, I expect to **always**
get 93 objects/structures of one of those types.

But my results are quite different. Here's what I get

    
    
    >>> import win32net
    >>> import win32api
    >>> server = "\\\\" + win32api.GetComputerName()
    >>> users = []
    >>> group = u"MyGroup"
    >>> (users, total, res) = win32net.NetLocalGroupGetMembers(server, group, 0)
    >>> len(users)
    93
    >>> (users, total, res) = win32net.NetLocalGroupGetMembers(server, group, 1)
    >>> len(users)
    56
    >>> (users, total, res) = win32net.NetLocalGroupGetMembers(server, group, 2)
    >>> len(users)
    39
    >>> (users, total, res) = win32net.NetLocalGroupGetMembers(server, group, 3)
    >>> len(users)
    68
    

I expect to get 93 users. And then I want the 93 usernames. The username is
accessible when specifying level=1 and with that param, only 56 are returned.

Any clue ? Thanks.


Answer: The call returns different numbers of results due to the size of the data for
the requested level. You can use the returned resume handle to continue
fetching the rest, or increase the buffer size to get all results in one call.

Here's the full parameter list from the pywin32 help file:
NetLocalGroupGetMembers(server, groupName , level , resumeHandle , prefLen )

