printerShare の allowedGroup を作成する
[アーティクル]
01/20/2022
3 人の共同作成者
この記事の内容
名前空間: microsoft.graph
指定したグループ アクセス権を付与して、関連付けられた printerShare に印刷ジョブを 送信します 。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可 」を参照してください。
ユニバーサル 印刷サービスを使用するには、ユーザーまたはアプリのテナントに、次の表に示すアクセス許可に加えて、アクティブなユニバーサル印刷サブスクリプションが必要です。 サインインしているユーザーはプリンター管理者 である必要があります 。
アクセス許可の種類
アクセス許可 (特権の小さいものから大きいものへ)
委任 (職場または学校のアカウント)
PrinterShare.ReadWrite.All
委任 (個人用 Microsoft アカウント)
サポートされていません。
アプリケーション
サポートされていません。
HTTP 要求
POST /print/printers/{printerId}/shares/{printerShareId}/allowedGroups/$ref
名前
説明
Authorization
ベアラー {token}。必須。
Content-Type
application/json. Required.
要求本文
要求本文で、次の例に示すように、形式を使用してグループ エンティティへの参照 @odata.id を指定します。
応答
成功した場合、このメソッドは 204 No Content 応答コードを返します。
例
要求
POST https://graph.microsoft.com/v1.0/print/shares/{printerShareId}/allowedGroups/$ref
Content-Type: application/json
{
"@odata.id": "https://graph.microsoft.com/v1.0/groups/{groupId}"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var group = new Group
{
AdditionalData = new Dictionary<string, object>()
{
{"@odata.id", "https://graph.microsoft.com/v1.0/groups/{groupId}"}
}
};
await graphClient.Print.Shares["{printerShare-id}"].AllowedGroups.References
.Request()
.AddAsync(group);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
const options = {
authProvider,
};
const client = Client.init(options);
const group = {
'@odata.id': 'https://graph.microsoft.com/v1.0/groups/{groupId}'
};
await client.api('/print/shares/{printerShareId}/allowedGroups/$ref')
.post(group);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/print/shares/{printerShareId}/allowedGroups/$ref"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphGroup *group = [[MSGraphGroup alloc] init];
NSError *error;
NSData *groupData = [group getSerializedDataWithError:&error];
[urlRequest setHTTPBody:groupData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Group group = new Group();
group.additionalDataManager().put("@odata.id", new JsonPrimitive("https://graph.microsoft.com/v1.0/groups/{groupId}"));
graphClient.print().shares("{printerShareId}").allowedGroups().references()
.buildRequest()
.post(group);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.New()
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.id": "https://graph.microsoft.com/v1.0/groups/{groupId}",
}
printerShareId := "printerShare-id"
result, err := graphClient.Print().SharesById(&printerShareId).AllowedGroups().$ref().Post(requestBody)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
Import-Module Microsoft.Graph.Devices.CloudPrint
$params = @{
"@odata.id" = "https://graph.microsoft.com/v1.0/groups/{groupId}"
}
New-MgPrintShareAllowedGroupByRef -PrinterShareId $printerShareId -BodyParameter $params
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
HTTP/1.1 204 No Content