本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用记录 AWS Directory Service 数据API调用 AWS CloudTrail
AWS Directory Service Data 与 AWS CloudTrail一项服务集成,该 AWS 服务在目录服务数据中提供用户、角色或服务所执行操作的记录。 CloudTrail 将所有对目录服务数据的API调用捕获为事件。捕获的呼叫包括来自目录服务数据控制台的调用和对目录服务数据API操作的代码调用。如果您创建跟踪,则可以将 CloudTrail事件持续传输到 Amazon S3 存储桶,包括目录服务数据的事件。使用收集的信息 CloudTrail,您可以确定向 Directory Service Data 发出的请求、发出请求的 IP 地址、谁发出了请求、何时发出请求以及其他详细信息。
要了解更多信息 CloudTrail,请参阅《AWS CloudTrail 用户指南》。
Directory Service 中的数据信息 CloudTrail
CloudTrail 在您创建账户 AWS 账户 时已在您的账户上启用。当 Directory Service Data 中出现支持的事件活动(管理事件)时,该活动将与其他 AWS 服务 CloudTrail 事件一起记录在事件历史记录中。您可以在中查看、搜索和下载最近 90 天的管理事件 AWS 账户。有关更多信息,请参阅使用事件历史记录查看 CloudTrail 事件。查看活动历史记录不收取任何费用。
要持续记录您的 AWS 账户事件(包括 Directory Service Data 的事件),请创建跟踪。跟踪允许 CloudTrail 将日志文件传输到 Amazon S3 存储桶。预设情况下,在控制台中创建跟踪记录时,此跟踪记录应用于所有 AWS 区域。跟踪记录 AWS 分区中所有区域的事件,并将日志文件传送到您指定的 Amazon S3 存储桶。此外,您可以配置其他 AWS 服务,以进一步分析和处理 CloudTrail 日志中收集的事件数据。有关更多信息,请参阅下列内容:
所有目录服务数据操作均由《目录服务数据参考》记录 CloudTrail 并记录在《目录服务数据API参考》中。例如,调用DescribeUser
和SearchGroups
操作会在 CloudTrail 日志文件中生成条目。AddGroupMember
每个事件或日记账条目都包含有关生成请求的人员信息。身份信息有助于您确定以下内容:
-
请求是使用 root 还是 AWS Identity and Access Management (IAM) 用户凭据发出。
-
请求是使用角色还是联合用户的临时安全凭证发出的。
-
请求是否由其他 AWS 服务发出。
有关更多信息,请参阅CloudTrail userIdentity 元素。
了解 Directory Service 数据日志文件条目
跟踪是一种配置,允许将事件作为日志文件传输到您指定的 Amazon S3 存储桶。 CloudTrail 日志文件包含一个或多个日志条目。事件代表来自任何来源的单个请求,包括有关请求的操作、操作的日期和时间、请求参数等的信息。 CloudTrail 日志文件不是公共API调用的有序堆栈跟踪,因此它们不会按任何特定的顺序出现。
以下示例显示了演示该CreateUser操作的 CloudTrail 日志条目。
{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "1234567890abcdef0:admin-role", "arn": "arn:aws:sts::111222333444:assumed-role/AdAdmin/admin-role", "accountId": "111222333444", "accessKeyId": "021345abcdef6789", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "1234567890abcdef0", "arn": "arn:aws:iam::111222333444:role/AdAdmin", "accountId": "111222333444", "userName": "AdAdmin" }, "attributes": { "creationDate": "2023-05-30T18:22:38Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-05-30T19:17:03Z", "eventSource": "ds.amazonaws.com", "eventName": "CreateUser", "awsRegion": "ap-northeast-2", "sourceIPAddress": ": 10.24.34.0", "userAgent": "aws-cli/2.9.20 Python/3.11.1 Darwin/21.6.0 source/x86_64 prompt/off command/ds-data.create-user", "requestParameters": { "directoryId": "d-1234567890", "sAMAccountName": "johnsmith", "emailAddress": "HIDDEN_DUE_TO_SECURITY_REASONS", "givenName": "HIDDEN_DUE_TO_SECURITY_REASONS", "surname": "HIDDEN_DUE_TO_SECURITY_REASONS", "otherAttributes": { "physicalDeliveryOfficeName": { "s": "HIDDEN_DUE_TO_SECURITY_REASONS" }, "telephoneNumber": { "s": "HIDDEN_DUE_TO_SECURITY_REASONS" }, "streetAddress": { "s": "HIDDEN_DUE_TO_SECURITY_REASONS" }, "displayName": { "s": "HIDDEN_DUE_TO_SECURITY_REASONS" }, "homePhone": { "s": "HIDDEN_DUE_TO_SECURITY_REASONS" }, "postalCode": { "s": "HIDDEN_DUE_TO_SECURITY_REASONS" }, "description": { "s": "HIDDEN_DUE_TO_SECURITY_REASONS" } }, "clientToken": "createUserToken4" }, "responseElements": { "directoryId": "d-1234567890", "sID": "S-1-5-21-1234567890-123456789-123456789-1234", "sAMAccountName": "johnsmith" }, "requestID": "4567ab89-c12d-3333-2222-1e0012f34a7c", "eventID": "1234567b-f0a0-12ab-3c45-d678900d1255", "readOnly": false, "resources": [ { "accountId": "111222333444", "type": "AWS::DirectoryService::MicrosoftAD", "ARN": "arn:aws:ds:ap-northeast-2:111222333444:directory/d-1234567890" } ], "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111222333444", "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "ds-data.ap-northeast-2.amazonaws.com" } },
以下示例显示了演示该ListUsers操作的 CloudTrail 日志条目。
不创建或修改对象的操作会返回空响应。
{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "1234567890abcdef0:admin-role", "arn": "arn:aws:sts::111222333444:assumed-role/AdAdmin/admin-role", "accountId": "111222333444", "accessKeyId": "021345abcdef6789", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "1234567890abcdef0", "arn": "arn:aws:iam::111222333444:role/AdAdmin", "accountId": "111222333444", "userName": "AdAdmin" }, "attributes": { "creationDate": "2023-05-30T18:22:38Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-05-30T18:22:52Z", "eventSource": "ds.amazonaws.com", "eventName": "ListUsers", "awsRegion": "ap-northeast-2", "sourceIPAddress": "10.24.34.0", "userAgent": "aws-cli/2.9.20 Python/3.11.1 Darwin/21.6.0 source/x86_64 prompt/off command/ds-data.list-users", "requestParameters": { "directoryId": "d-1234567890", "maxResults": 1 }, "responseElements": null, "requestID": "4567ab89-c12d-3333-2222-1e0012f34a7c", "eventID": "1234567b-f0a0-12ab-3c45-d678900d1244", "readOnly": true, "resources": [ { "accountId": "111222333444", "type": "AWS::DirectoryService::MicrosoftAD", "ARN": "arn:aws:ds:ap-northeast-2:111222333444:directory/d-1234567890" } ], "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111222333444", "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "ds-data.ap-northeast-2.amazonaws.com" } }
以下示例显示了演示该ListGroups操作的 CloudTrail 日志条目。
注意
该NextToken
元素已从所有日志条目中删除。
{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "1234567890abcdef0:admin-role", "arn": "arn:aws:sts::111222333444:assumed-role/AdAdmin/admin-role", "accountId": "111222333444", "accessKeyId": "021345abcdef6789", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "1234567890abcdef0", "arn": "arn:aws:iam::111222333444:role/AdAdmin", "accountId": "111222333444", "userName": "AdAdmin" }, "attributes": { "creationDate": "2023-05-30T18:22:38Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-05-30T18:29:15Z", "eventSource": "ds.amazonaws.com", "eventName": "ListGroups", "awsRegion": "ap-northeast-2", "sourceIPAddress": "10.24.34.0", "userAgent": "aws-cli/2.9.20 Python/3.11.1 Darwin/21.6.0 source/x86_64 prompt/off command/ds-data.list-groups", "requestParameters": { "directoryId": "d-1234567890", "nextToken": "REDACTED", "maxResults": 1 }, "responseElements": null, "requestID": "4567ab89-c12d-3333-2222-1e0012f34a7c", "eventID": "1234567b-f0a0-12ab-3c45-d678900d1255", "readOnly": true, "resources": [ { "accountId": "111222333444", "type": "AWS::DirectoryService::MicrosoftAD", "ARN": "arn:aws:ds:ap-northeast-2:111222333444:directory/d-1234567890" } ], "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111222333444", "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "ds-data.ap-northeast-2.amazonaws.com" } }
异常错误的日志条目
以下示例显示了 “访问被拒绝” 错误的 CloudTrail 日志条目。有关此错误的帮助,请参阅《IAM用户指南》中的 “排除访问被拒绝错误消息”。
注意
“拒绝访问” 日志不显示请求参数。
{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "1234567890abcdef0:admin-role", "arn": "arn:aws:sts::111222333444:assumed-role/AdAdmin/admin-role", "accountId": "111222333444", "accessKeyId": "021345abcdef6789", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "1234567890abcdef0", "arn": "arn:aws:iam::111222333444:role/AdAdmin", "accountId": "111222333444", "userName": "AdAdmin" }, "attributes": { "creationDate": "2023-05-31T23:25:49Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-05-31T23:38:18Z", "eventSource": "ds.amazonaws.com", "eventName": "CreateUser", "awsRegion": "ap-northeast-2", "sourceIPAddress": "10.24.34.0", "userAgent": "aws-cli/2.9.20 Python/3.11.1 Darwin/21.6.0 source/x86_64 prompt/off command/ds-data.create-user", "errorCode": "AccessDenied", "errorMessage": "User: arn:aws:sts::111222333444:assumed-role/AdAdmin/admin-role is not authorized to perform: ds-data:CreateUser on resource: arn:aws:ds:ap-northeast-2:111222333444:directory/d-1234567890 because no identity-based policy allows the ds-data:CreateUser action", "requestParameters": null, "responseElements": null, "requestID": "4567ab89-c12d-3333-2222-1e0012f34a7c", "eventID": "1234567b-f0a0-12ab-3c45-d678900d1255", "readOnly": false, "resources": [ { "accountId": "111222333444", "type": "AWS::DirectoryService::MicrosoftAD", "ARN": "arn:aws:ds:ap-northeast-2:111222333444:directory/d-1234567890" } ], "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111222333444", "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "ds-data.ap-northeast-2.amazonaws.com" } }
以下示例显示了 “未找到资源” 错误的 CloudTrail 日志条目。
{ "eventVersion": "1.08", "userIdentity": { "type": "AssumedRole", "principalId": "1234567890abcdef0:admin-role", "arn": "arn:aws:sts::111222333444:assumed-role/AdAdmin/admin-role", "accountId": "111222333444", "accessKeyId": "021345abcdef6789", "sessionContext": { "sessionIssuer": { "type": "Role", "principalId": "1234567890abcdef0", "arn": "arn:aws:iam::111222333444:role/AdAdmin", "accountId": "111222333444", "userName": "AdAdmin" }, "attributes": { "creationDate": "2023-05-30T20:41:50Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-05-30T21:10:16Z", "eventSource": "ds.amazonaws.com", "eventName": "DescribeUser", "awsRegion": "ap-northeast-2", "sourceIPAddress": "10.24.34.0", "userAgent": "aws-cli/2.9.20 Python/3.11.1 Darwin/21.6.0 source/x86_64 prompt/off command/ds-data.describe-user", "errorCode": "ResourceNotFoundException", "errorMessage": "User not found in directory d-1234567890.", "requestParameters": { "directoryId": "d-1234567890", "sAMAccountName": "nonExistingUser", "otherAttributes": [ "co", "givenName", "sn", "telephoneNumber" ] }, "responseElements": null, "requestID": "4567ab89-c12d-3333-2222-1e0012f34a7c", "eventID": "1234567b-f0a0-12ab-3c45-d678900d1255", "readOnly": true, "resources": [ { "accountId": "111222333444", "type": "AWS::DirectoryService::MicrosoftAD", "ARN": "arn:aws:ds:ap-northeast-2:111222333444:directory/d-1234567890" } ], "eventType": "AwsApiCall", "managementEvent": true, "recipientAccountId": "111222333444" "eventCategory": "Management", "tlsDetails": { "tlsVersion": "TLSv1.3", "cipherSuite": "TLS_AES_128_GCM_SHA256", "clientProvidedHostHeader": "ds-data.ap-northeast-2.amazonaws.com" } }