

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 记录可配置 AD 同步错误
<a name="logging-ad-sync-errors"></a>

您可以启用可配置 Active Directory（AD）同步配置的日志记录功能，用以接收包含同步过程中可能发生的错误相关信息的日志。利用这些日志，您可以监控可配置 AD 同步是否存在问题，在有问题时采取措施。您可以将日志发送到亚马逊 CloudWatch 日志组、亚马逊简单存储服务 (Amazon S3) Service 存储桶或支持跨账户传输的亚马逊数据 Firehose，Amazon S3 存储桶和 Firehose 支持跨账户传输。

有关限制、权限和公开日志的更多信息，请参阅[从中 AWS 服务启用日志记录](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html)。

**注意**  
您需要为日志记录支付费用。有关更多信息，请参阅 [Amazon CloudWatch 定价页面上的销售](https://aws.amazon.com/cloudwatch/pricing/)[日志](https://aws.amazon.com/cloudwatch/pricing/#Vended_Logs)。

## 启用可配置 AD 同步错误日志
<a name="enable-logging-ad-sync-errors"></a>

1. 登录到 [IAM Identity Center 控制台](https://console.aws.amazon.com/singlesignon/)。

1. 选择**设置**。

1. 在**设置**页面上，选择**身份源**选项卡，从中选择**操作**，然后选择**管理日记**。

1. 选择**添加日志传输**和以下某个目标类型。

   1. 选择 “收**到 Amazon CloudWatch 日志**”。再选择或输入目标日志组。

   1. 选择**到 Amazon S3**。再选择或输入目标存储桶。

   1. 选择**到 Firehose**。再选择或输入目标传输流。

1. 选择**提交**。

## 禁用可配置 AD 同步错误日志
<a name="disable-logging-ad-sync-errors"></a>

1. 登录到 [IAM Identity Center 控制台](https://console.aws.amazon.com/singlesignon/)。

1. 选择**设置**。

1. 在**设置**页面上，选择**身份源**选项卡，从中选择**操作**，然后选择**管理日记**。

1. 为要删除的目标选择**删除**。

1. 选择**提交**。

## 可配置 AD 同步错误日志字段
<a name="logging-ad-sync-errors-fields"></a>

请参阅如下列表，了解可能的错误日志字段。

`sync_profile_name`  
同步配置文件的名称。

`error_code`  
表示发生了哪种错误类型的错误代码。

`error_message`  
包含有关所发生错误的详细信息的一条消息。

`sync_source`  
同步源是指要从中同步实体的位置。对 IAM Identity Center 而言，这是指由 Directory Service管理的 Active Directory（AD）。同步源包含受影响目录的域和 ARN。

`sync_target`  
同步目标是指要保存实体的目标位置。对 IAM Identity Center 而言，这是指身份存储。同步目标包含受影响的身份存储 ARN。

`source_entity_id`  
导致错误的实体的唯一标识符。对 IAM Identity Center 而言，这是指实体的 SID。

`source_entity_type`  
导致错误的实体类型。该值可以是 `USER` 或 `GROUP`。

`eventTimestamp`  
错误出现的时间戳。

## 可配置 AD 同步错误日志示例
<a name="logging-ad-sync-errors-examples"></a>

**示例 1：AD 目录密码过期的错误日志**

```
{
    "sync_profile_name": "EXAMPLE-PROFILE-NAME",
    "error" : {
        "error_code": "InvalidDirectoryCredentials", 
        "error_message": "The password for your AD directory has expired. Please reset the password to allow Identity Sync to access the directory." 
    },
    "sync_source": {
        "arn": "arn:aws:ds:us-east-1:123456789:directory/d-123456",
        "domain": "EXAMPLE.com" 
    },
    "eventTimestamp": "1683355579981"
}
```

**示例 2：用户的用户名不唯一的错误日志**

```
{
    "sync_profile_name": "EXAMPLE-PROFILE-NAME",
    "error" : {
        "error_code": "ConflictError", 
        "error_message": "The source entity has a username conflict with the sync target. Please verify that the source identity has a unique username in the target." 
    },
    "sync_source": {
        "arn": "arn:aws:ds:us-east-1:111122223333:directory/d-123456",
        "domain": "EXAMPLE.com"
    },
    "sync_target": {
        "arn": "arn:aws:identitystore::111122223333:identitystore/d-123456" 
    },
    "source_entity_id": "SID-1234",
    "source_entity_type": "USER",
    "eventTimestamp": "1683355579981"
}
```