Skip to content

list_groups_for_member

list_groups_for_member(
    directory_id: DirectoryId,
    sam_account_name: MemberName,
    *,
    config_overrides: Optional[DirectoryServiceDataClientConfig] = None,
    realm: Optional[Realm] = None,
    member_realm: Optional[Realm] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
) -> ListGroupsForMemberResult

Returns group information for the specified member.

This operation supports pagination with the use of the NextToken request and response parameters. If more results are available, the ListGroupsForMember.NextToken member contains a token that you pass in the next call to ListGroupsForMember. This retrieves the next set of items.

You can also specify a maximum number of return results with the MaxResults parameter.

Parameters:

  • directory_id (DirectoryId) –

    The identifier (ID) of the directory that's associated with the member.

  • realm (Optional[Realm], default: None ) –

    The domain name that's associated with the group.

    This parameter is optional, so you can return groups outside of your Managed Microsoft AD domain. When no value is defined, only your Managed Microsoft AD groups are returned.

    This value is case insensitive and defaults to your Managed Microsoft AD domain.

  • member_realm (Optional[Realm], default: None ) –

    The domain name that's associated with the group member.

    This parameter is optional, so you can limit your results to the group members in a specific domain.

    This parameter is case insensitive and defaults to Realm

  • sam_account_name (MemberName) –

    The SAMAccountName of the user, group, or computer that's a member of the group.

  • next_token (Optional[NextToken], default: None ) –

    An encoded paging token for paginated calls that can be passed back to retrieve the next page.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to be returned per request.

Raises:

  • AccessDeniedException –

    You don't have permission to perform the request or access the directory. It can also occur when the DirectoryId doesn't exist or the user, member, or group might be outside of your organizational unit (OU).

    Make sure that you have the authentication and authorization to perform the action. Review the directory information in the request, and make sure that the object isn't outside of your OU.

  • DirectoryUnavailableException –

    The request could not be completed due to a problem in the configuration or current state of the specified directory.

  • InternalServerException –

    The operation didn't succeed because an internal error occurred. Try again later.

  • ResourceNotFoundException –

    The resource couldn't be found.

  • ThrottlingException –

    The limit on the number of requests per second has been exceeded.

  • ValidationException –

    The request isn't valid. Review the details in the error message to update the invalid parameters or values in your request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To list groups for a member The following command

>>> client.list_groups_for_member(directory_id='d-12233abcde', sam_account_name='twhitlock', member_realm='example.local', realm='examplecorp.com')
Source code in docs_src/capo_directory_service_data/_services/directory_service_data.py
def list_groups_for_member(
    self,
    directory_id: "capo_directory_service_data.types.directory_id.DirectoryId",
    sam_account_name: "capo_directory_service_data.types.member_name.MemberName",
    *,
    config_overrides: Optional[DirectoryServiceDataClientConfig] = None,
    realm: Optional["capo_directory_service_data.types.realm.Realm"] = None,
    member_realm: Optional["capo_directory_service_data.types.realm.Realm"] = None,
    next_token: Optional[
        "capo_directory_service_data.types.next_token.NextToken"
    ] = None,
    max_results: Optional[
        "capo_directory_service_data.types.max_results.MaxResults"
    ] = None,
) -> "capo_directory_service_data.types.list_groups_for_member_result.ListGroupsForMemberResult":
    """<p> Returns group information for the specified member. </p> <p> This operation supports pagination with the use of the <code>NextToken</code> request and response parameters. If more results are available, the <code>ListGroupsForMember.NextToken</code> member contains a token that you pass in the next call to <code>ListGroupsForMember</code>. This retrieves the next set of items. </p> <p> You can also specify a maximum number of return results with the <code>MaxResults</code> parameter. </p>

    Args:
        directory_id: <p> The identifier (ID) of the directory that's associated with the member. </p>
        realm: <p> The domain name that's associated with the group. </p> <note> <p> This parameter is optional, so you can return groups outside of your Managed Microsoft AD domain. When no value is defined, only your Managed Microsoft AD groups are returned. </p> <p> This value is case insensitive and defaults to your Managed Microsoft AD domain. </p> </note>
        member_realm: <p> The domain name that's associated with the group member. </p> <note> <p> This parameter is optional, so you can limit your results to the group members in a specific domain. </p> <p> This parameter is case insensitive and defaults to <code>Realm</code> </p> </note>
        sam_account_name: <p> The <code>SAMAccountName</code> of the user, group, or computer that's a member of the group. </p>
        next_token: <p> An encoded paging token for paginated calls that can be passed back to retrieve the next page. </p>
        max_results: <p> The maximum number of results to be returned per request. </p>

    Raises:
        capo_directory_service_data.errors.access_denied_exception.AccessDeniedException: <p> You don't have permission to perform the request or access the directory. It can also occur when the <code>DirectoryId</code> doesn't exist or the user, member, or group might be outside of your organizational unit (OU). </p> <p> Make sure that you have the authentication and authorization to perform the action. Review the directory information in the request, and make sure that the object isn't outside of your OU. </p>
        capo_directory_service_data.errors.directory_unavailable_exception.DirectoryUnavailableException: <p> The request could not be completed due to a problem in the configuration or current state of the specified directory. </p>
        capo_directory_service_data.errors.internal_server_exception.InternalServerException: <p> The operation didn't succeed because an internal error occurred. Try again later. </p>
        capo_directory_service_data.errors.resource_not_found_exception.ResourceNotFoundException: <p> The resource couldn't be found. </p>
        capo_directory_service_data.errors.throttling_exception.ThrottlingException: <p> The limit on the number of requests per second has been exceeded. </p>
        capo_directory_service_data.errors.validation_exception.ValidationException: <p> The request isn't valid. Review the details in the error message to update the invalid parameters or values in your request. </p>
        capo_directory_service_data.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list groups for a member
        The following command

        >>> client.list_groups_for_member(directory_id='d-12233abcde', sam_account_name='twhitlock', member_realm='example.local', realm='examplecorp.com')
    """

    def _handler(
        req: "OperationRequest[capo_directory_service_data.types.list_groups_for_member_request.ListGroupsForMemberRequest]",
    ) -> OperationResponse[
        "capo_directory_service_data.types.list_groups_for_member_result.ListGroupsForMemberResult"
    ]:
        import capo_directory_service_data._operations.directory_service_data.list_groups_for_member

        output, http_response = (
            capo_directory_service_data._operations.directory_service_data.list_groups_for_member.list_groups_for_member(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_directory_service_data.types.list_groups_for_member_request.ListGroupsForMemberRequest",
    ) -> dict[str, Any]:
        import capo_directory_service_data.types.list_groups_for_member_request

        return capo_directory_service_data.types.list_groups_for_member_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_directory_service_data.types.list_groups_for_member_result.ListGroupsForMemberResult",
    ) -> dict[str, Any]:
        import capo_directory_service_data.types.list_groups_for_member_result

        return capo_directory_service_data.types.list_groups_for_member_result.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "ListGroupsForMember",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_directory_service_data.types.list_groups_for_member_request.ListGroupsForMemberRequest = {
        "directory_id": directory_id,
        "sam_account_name": sam_account_name,
    }
    if realm is not None:
        input_["realm"] = realm
    if member_realm is not None:
        input_["member_realm"] = member_realm
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output