本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 記錄 AWS 目錄服務資料API呼叫 AWS CloudTrail
AWS Directory Service Data 與 整合 AWS CloudTrail,該服務提供 Directory Service Data AWS 中使用者、角色或服務所採取動作的記錄。 CloudTrail 會將 Directory Service Data 的所有API呼叫擷取為事件。擷取的呼叫包括來自 Directory Service Data 主控台的呼叫,以及 Directory Service Data API操作的程式碼呼叫。如果您建立追蹤,則可以啟用事件 CloudTrail連續交付至 Amazon S3 儲存貯體,包括目錄服務資料的事件。使用 所收集的資訊 CloudTrail,您可以判斷對 Directory Service Data 提出的請求、提出請求的 IP 地址、提出請求的人員、提出的時間,以及其他詳細資訊。
若要進一步了解 CloudTrail,請參閱 AWS CloudTrail 使用者指南 。
中的目錄服務資料資訊 CloudTrail
CloudTrail 當您建立 帳戶 AWS 帳戶 時, 會在 上啟用 。當 Directory Service Data 中發生支援的事件活動 (管理事件) 時,該活動會與 CloudTrail 事件歷史記錄 中的其他 AWS 服務事件一起記錄在事件中。您可以在 中檢視、搜尋和下載過去 90 天的管理事件 AWS 帳戶。如需詳細資訊,請參閱使用事件歷史記錄檢視 CloudTrail 事件。檢視事件歷史記錄 無需付費。
如需 中事件的持續記錄 AWS 帳戶,包括目錄服務資料的事件,請建立追蹤。追蹤可讓 CloudTrail 將日誌檔案交付至 Amazon S3 儲存貯體。依預設,當您在主控台中建立追蹤時,該追蹤會套用至所有的 AWS 區域。追蹤會記錄 AWS 分割區中所有 區域的事件,並將日誌檔案傳送至您指定的 Amazon S3 儲存貯體。此外,您可以設定其他服務 AWS ,以進一步分析 CloudTrail 日誌中收集的事件資料並對其採取行動。如需詳細資訊,請參閱下列內容:
所有 Directory Service Data 動作都會由 記錄, CloudTrail 並記錄在 Directory Service Data API Reference 中。例如, 呼叫 AddGroupMember
,DescribeUser
而 SearchGroups
動作會在 CloudTrail 日誌檔案中產生項目。
每一筆事件或日誌專案都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項:
-
請求是使用根 還是 AWS Identity and Access Management (IAM) 使用者憑證提出。
-
提出該請求時,是否使用了特定角色或聯合身分使用者的暫時安全憑證。
-
該請求是否由其他 AWS 服務提出。
如需詳細資訊,請參閱 CloudTrail userIdentity 元素 。
了解 Directory Service Data 日誌檔案項目
追蹤是一種組態,可讓您將事件作為日誌檔案交付至您指定的 Amazon S3 儲存貯體。 CloudTrail 日誌檔案包含一或多個日誌項目。事件代表來自任何來源的單一請求,並包含所請求動作、動作的日期和時間、請求參數等資訊。 CloudTrail log 檔案不是公開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 日誌項目。
未建立或修改物件的動作會傳回 null 回應。
{ "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 使用者指南 中的對存取遭拒錯誤訊息進行故障診斷。
注意
Access Denied 日誌不會顯示請求參數。
{ "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" } }