Directory Services

IADsGroup::Members

The IADsGroup::Members method retrieves all the members of the group. It gets the IADsMembers interface on an ADSI collection object that represents the members of this group.

HRESULT Members( 
  IADsMembers** ppMembers
);

Parameters

ppMembers
[out] Pointer to a pointer to the IADsMembers interface that supports methods to identify, manage, and select members of this group.

Return Values

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

Example Code [Visual Basic]

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

Example Code [C++]

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

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.

See Also

IADsMembers, IADsGroup, IADsGroup Property Methods, ADSI Error Codes