为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
权限类型
最低特权权限
更高特权权限
委派(工作或学校帐户)
InformationProtectionPolicy.Read
不可用。
委派(个人 Microsoft 帐户)
不支持。
不支持。
应用程序
InformationProtectionPolicy.Read.All
不可用。
HTTP 请求
若要评估为已登录用户 (委派权限) 或指定用户 (应用程序权限) :
POST /users/{usersId}/security/informationProtection/sensitivityLabels/evaluateClassificationResults
POST /users/me/security/informationProtection/sensitivityLabels/evaluateClassificationResults
若要评估为服务主体 (应用程序权限) :
POST /users/security/informationProtection/sensitivityLabels/evaluateClassificationResults
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Users.Item.Security.InformationProtection.SensitivityLabels.MicrosoftGraphSecurityEvaluateClassificationResults;
using Microsoft.Graph.Beta.Models.Security;
var requestBody = new EvaluateClassificationResultsPostRequestBody
{
ContentInfo = new ContentInfo
{
OdataType = "#microsoft.graph.security.contentInfo",
ContentFormat = "File",
Identifier = "c:\user\new.docx",
State = ContentState.Rest,
Metadata = new List<KeyValuePair>
{
},
AdditionalData = new Dictionary<string, object>
{
{
"format@odata.type" , "#microsoft.graph.security.contentFormat"
},
{
"format" , "default"
},
{
"state@odata.type" , "#microsoft.graph.security.contentState"
},
},
},
ClassificationResults = new List<ClassificationResult>
{
new ClassificationResult
{
SensitiveTypeId = "50842eb7-edc8-4019-85dd-5a5c1f2bb085",
Count = 7,
ConfidenceLevel = 99,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].Security.InformationProtection.SensitivityLabels.MicrosoftGraphSecurityEvaluateClassificationResults.PostAsEvaluateClassificationResultsPostResponseAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("User-Agent", "ContosoLOBApp/1.0");
});
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.users.item.security.informationprotection.sensitivitylabels.microsoftgraphsecurityevaluateclassificationresults.EvaluateClassificationResultsPostRequestBody evaluateClassificationResultsPostRequestBody = new com.microsoft.graph.beta.users.item.security.informationprotection.sensitivitylabels.microsoftgraphsecurityevaluateclassificationresults.EvaluateClassificationResultsPostRequestBody();
com.microsoft.graph.beta.models.security.ContentInfo contentInfo = new com.microsoft.graph.beta.models.security.ContentInfo();
contentInfo.setOdataType("#microsoft.graph.security.contentInfo");
contentInfo.setContentFormat("File");
contentInfo.setIdentifier("c:\user\new.docx");
contentInfo.setState(com.microsoft.graph.beta.models.security.ContentState.Rest);
LinkedList<com.microsoft.graph.beta.models.security.KeyValuePair> metadata = new LinkedList<com.microsoft.graph.beta.models.security.KeyValuePair>();
contentInfo.setMetadata(metadata);
HashMap<String, Object> additionalData = new HashMap<String, Object>();
additionalData.put("format@odata.type", "#microsoft.graph.security.contentFormat");
additionalData.put("format", "default");
additionalData.put("state@odata.type", "#microsoft.graph.security.contentState");
contentInfo.setAdditionalData(additionalData);
evaluateClassificationResultsPostRequestBody.setContentInfo(contentInfo);
LinkedList<com.microsoft.graph.beta.models.security.ClassificationResult> classificationResults = new LinkedList<com.microsoft.graph.beta.models.security.ClassificationResult>();
com.microsoft.graph.beta.models.security.ClassificationResult classificationResult = new com.microsoft.graph.beta.models.security.ClassificationResult();
classificationResult.setSensitiveTypeId("50842eb7-edc8-4019-85dd-5a5c1f2bb085");
classificationResult.setCount(7);
classificationResult.setConfidenceLevel(99);
classificationResults.add(classificationResult);
evaluateClassificationResultsPostRequestBody.setClassificationResults(classificationResults);
var result = graphClient.users().byUserId("{user-id}").security().informationProtection().sensitivityLabels().microsoftGraphSecurityEvaluateClassificationResults().post(evaluateClassificationResultsPostRequestBody, requestConfiguration -> {
requestConfiguration.headers.add("User-Agent", "ContosoLOBApp/1.0");
});