Skip to content

describe_user

describe_user(
    directory_id: DirectoryId,
    sam_account_name: UserName,
    *,
    config_overrides: Optional[DirectoryServiceDataClientConfig] = None,
    other_attributes: Optional[LdapDisplayNameList] = None,
    realm: Optional[Realm] = None,
) -> DescribeUserResult

Returns information about a specific user.

Parameters:

  • directory_id (DirectoryId) –

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

  • sam_account_name (UserName) –

    The name of the user.

  • other_attributes (Optional[LdapDisplayNameList], default: None ) –

    One or more attribute names to be returned for the user. A key is an attribute name, and the value is a list of maps. For a list of supported attributes, see Directory Service Data Attributes.

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

    The domain name that's associated with the user.

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

    This value is case insensitive.

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 return the attributes of a user The following command returns the mapped attributes for a user along with the department, manager, IP phone, and date the user last set a password.

>>> client.describe_user(directory_id='d-12233abcde', other_attributes=['department', 'manager', 'ipPhone', 'pwdLastSet'], realm='examplecorp.com', sam_account_name='twhitlock')
Source code in docs_src/capo_directory_service_data/_services/directory_service_data.py
def describe_user(
    self,
    directory_id: "capo_directory_service_data.types.directory_id.DirectoryId",
    sam_account_name: "capo_directory_service_data.types.user_name.UserName",
    *,
    config_overrides: Optional[DirectoryServiceDataClientConfig] = None,
    other_attributes: Optional[
        "capo_directory_service_data.types.ldap_display_name_list.LdapDisplayNameList"
    ] = None,
    realm: Optional["capo_directory_service_data.types.realm.Realm"] = None,
) -> "capo_directory_service_data.types.describe_user_result.DescribeUserResult":
    """<p>Returns information about a specific user.</p>

    Args:
        directory_id: <p> The identifier (ID) of the directory that's associated with the user. </p>
        sam_account_name: <p> The name of the user. </p>
        other_attributes: <p> One or more attribute names to be returned for the user. A key is an attribute name, and the value is a list of maps. For a list of supported attributes, see <a href="https://docs.aws.amazon.com/directoryservice/latest/admin-guide/ad_data_attributes.html">Directory Service Data Attributes</a>. </p>
        realm: <p> The domain name that's associated with the user. </p> <note> <p> This parameter is optional, so you can return users outside your Managed Microsoft AD domain. When no value is defined, only your Managed Microsoft AD users are returned. </p> <p> This value is case insensitive. </p> </note>

    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 return the attributes of a user
        The following command returns the mapped attributes for a user along with the department, manager, IP phone, and date the user last set a password.

        >>> client.describe_user(directory_id='d-12233abcde', other_attributes=['department', 'manager', 'ipPhone', 'pwdLastSet'], realm='examplecorp.com', sam_account_name='twhitlock')
    """

    def _handler(
        req: "OperationRequest[capo_directory_service_data.types.describe_user_request.DescribeUserRequest]",
    ) -> OperationResponse[
        "capo_directory_service_data.types.describe_user_result.DescribeUserResult"
    ]:
        import capo_directory_service_data._operations.directory_service_data.describe_user

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

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

        return (
            capo_directory_service_data.types.describe_user_result.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("DescribeUser", redact_output=_redact_output),
    )
    input_: capo_directory_service_data.types.describe_user_request.DescribeUserRequest = {
        "directory_id": directory_id,
        "sam_account_name": sam_account_name,
    }
    if other_attributes is not None:
        input_["other_attributes"] = other_attributes
    if realm is not None:
        input_["realm"] = realm

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