【问题标题】:Office 365 Management Activity API - Query using User ID or File IDOffice 365 管理活动 API - 使用用户 ID 或文件 ID 进行查询
【发布时间】:2018-10-08 11:09:28
【问题描述】:

我正在尝试从管理活动 API 获取 Office 365 审核日志。在为所需的内容类型创建订阅后,我能够从订阅/内容 API 中获取数据。

例子:-

查询:https://manage.office.com/api/v1.0/{tenant-id}/activity/feed/audit/xxxxx$xxxxx$audit_sharepoint$Audit_SharePoint

回复:

[
  {
        "CreationTime": "2018-10-08T10:13:15",
        "Id": "xxxxx",
        "Operation": "FileDownloaded",
        "OrganizationId": "xxxxx",
        "RecordType": 6,
        "UserKey": "xxx|membership|xxxxxxx@live.com",
        "UserType": 0,
        "Version": 1,
        "Workload": "OneDrive",
        "ClientIP": "xx.xx.xx.xx",
        "ObjectId": "xxxxxxx",
        "UserId": "xxxxxx",
        "ApplicationId": "xxxxxx",
        "CorrelationId": "xxxxxx",
        "EventSource": "SharePoint",
        "ItemType": "File",
        "ListId": "xxxxx",
        "ListItemUniqueId": "xxxxx",
        "Site": "xxxxx",
        "UserAgent": "xxxxx",
        "WebId": "xxxxx",
        "SourceFileExtension": "jpg",
        "SiteUrl": "xxxxx",
        "SourceFileName": "xxxxx.jpg",
        "SourceRelativeUrl": "xxxxx/xxxxx/xxxxx"
   },
   {..},{..}
]

我需要获取特定用户执行的操作或对特定文件执行的操作的日志。这可以通过 MSGraph 的安全与合规中心的审核搜索来实现。

API 有没有办法根据 UserId 或 ObjectId 字段(可能是查询参数)过滤其响应?

【问题讨论】:

    标签: office365


    【解决方案1】:

    很遗憾,Office 365 管理活动 API 端点不支持通过 AuditRecord(内容 blob)UserIdObjectId 属性进行过滤,仅支持以下参数:

    • contentType
    • startTimeendTime

    解决方法是在客户端过滤结果,如下所示:

    例子

    const requestUrl = `https://manage.office.com/api/v1.0/${tenantId}/activity/feed/audit/${contentId}$audit_sharepoint$Audit_SharePoint`;
    const options = {
       method: 'GET',
       headers: {
          "Content-Type": "application/json; charset=utf-8",
          "Authorization": "bearer " + accessToken
       }
    };
    
    const rawResponse = await fetch(requestUrl,options);
    const blobs = await rawResponse.json(); //get all blobs
    
    const blobsByUser = blobs.filter(blob => {
        return blob.UserId === "username@contoso.com";
    })
    

    【讨论】:

    • 感谢您的快速回复。您知道过滤功能是否会更新以支持其他参数?
    • @P.PratyushReddy,这个问题最好发给MS Graph team
    【解决方案2】:

    很遗憾,office 管理 API 尚不支持按对象 ID 进行过滤。 这已在此处记录 - https://docs.microsoft.com/en-us/office/office-365-management-api/troubleshooting-the-office-365-management-activity-api

    请阅读上述文档中的“我可以查询管理活动 API”查询。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-18
      • 2020-08-30
      相关资源
      最近更新 更多