IADsGroup::Members method (iads.h)

The IADsGroup::Members method retrieves a collection of the immediate members of the group. The collection does not include the members of other groups that are nested within the group.

The default implementation of this method uses LsaLookupSids to query name information for the group members. LsaLookupSids has a maximum limitation of 20480 SIDs it can convert, therefore that limitation also applies to this method.

Syntax

HRESULT Members(
  [out] IADsMembers **ppMembers
);

Parameters

[out] ppMembers

Pointer to an IADsMembers interface pointer that receives the collection of group members. The caller must release this interface when it is no longer required.

Return value

This method supports the standard return values, including S_OK. For more information and other return values, see ADSI Error Codes.

Remarks

The IADsMembersMembers method will use the same provider.

Examples

The following code example enumerates all members of a group.

Dim grp As IADsGroup
Dim memberList As IADsMembers
Dim member As IADs

On Error GoTo Cleanup
 
Set grp = GetObject("WinNT://Microsoft/Administrators")
Set memberList = grp.Members
For Each m In memberList
    Set member = m
    Debug.Print member.Name & "(" & member.Class & ")"
Next

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set grp = Nothing
    Set member = Nothing
    Set memberList = Nothing

The following code example enumerates all members of a group.

HRESULT EnumerateGroupMembers(IADsGroup *pGroup)
{
    IADsMembers *pMembers;
    HRESULT hr = S_OK;
    hr = pGroup->Members(&pMembers);
    if(FAILED(hr)){goto Cleanup;}
 
    hr = EnumMembers(pMembers);  // For more information and a code
                                    example, see IADsMembers::get__NewEnum.
    if(FAILED(hr)){goto Cleanup;}

Cleanup:
    if(pMembers)
        pMembers->Release();

    return hr;
}

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header iads.h
DLL Activeds.dll

See also

ADSI Error Codes

IADsGroup

IADsGroup Property Methods

IADsMembers