我可以使用Microsoft Graph API在我所属的MS Team中的所有Team / Group中搜索文件

问题描述 投票:0回答:2

我一直在使用以下API,建议在其中搜索TEAM_ID / GROUP_ID

https://graph.microsoft.com/v1.0/groups/GROUP_ID/drive/root/search(q='SEARCH_VALUE')

我希望在没有组ID的情况下搜索我所属的所有组,以搜索“团队驱动器”中的内容。任何线索将不胜感激。

azure-active-directory microsoft-graph microsoft-graph-teams
2个回答
0
投票

[O365组是微软云世界中许多事物的基础,一个团队是Office 365组的一个附加组件,Sharepoint(主要存储团队文件的地方)也是]

我不相信有一个图形查询可以返回您有权访问的所有驱动器文件。您将必须建立2个查询,一个查询您所属的组,然后循环遍历以对每个组进行搜索查询。要获取您所属的组的所有组ID,请访问/ getMemberGroups https://docs.microsoft.com/en-us/graph/api/user-getmembergroups?view=graph-rest-1.0&tabs=http

您可能可以使用powershell或简单的程序或实际上可以调用图形的任何语言来实现。


0
投票

group_id是必需的,请参见hereenter image description here

您可以尝试使用Powershell来获取所需的组,然后循环以请求MS Graph API。

#sign in your azure account
Connect-AzureAD

#get access token
function Get-AzureRMBearerToken
{
    [CmdletBinding()]
    Param
    (
        $TenantID,

        $AppID,

        $ClientSecret
    )

    $Result=Invoke-RestMethod -Uri https://login.microsoftonline.com/$TenantID/oauth2/token?api-version=1.0 -Method Post -Body @{"grant_type" = "client_credentials"; "resource" = "https://graph.microsoft.com/"; "client_id" = "$AppID"; "client_secret" = "$ClientSecret" }
    $Authorization = "{0} {1}" -f ($result.token_type , $result.access_token)
    $Authorization
}
$accessToken = Get-AzureRMBearerToken  -TenantID "{your tenant id}" -AppID "{application/client id}" -ClientSecret "{value in your client secret}"

#get all groups
$groups = Get-AzureADGroup -All

#request MS Graph API in the loop
Foreach($group in $groups){
    $url = "https://graph.microsoft.com/v1.0/groups/"+$group.ObjectId+"/drive/root/search(q='SEARCH_VALUE')"
    Invoke-RestMethod -Method Get -Uri $url -Headers @{ Authorization = $accessToken }
} 

注意:确保您的应用程序具有所需的权限。请参阅herehere

© www.soinside.com 2019 - 2024. All rights reserved.