As APIs na versão /beta no Microsoft Graph estão sujeitas a alterações. Não há suporte para o uso dessas APIs em aplicativos de produção. Para determinar se uma API está disponível na v1.0, use o seletor Versão.
Escolha a permissão ou permissões marcadas como menos privilegiadas para esta API. Utilize uma permissão ou permissões com privilégios mais elevados apenas se a sua aplicação o exigir. Para obter detalhes sobre as permissões delegadas e de aplicação, veja Tipos de permissão. Para saber mais sobre estas permissões, veja a referência de permissões.
Tipo de permissão
Permissões com menos privilégios
Permissões com privilégios superiores
Delegada (conta corporativa ou de estudante)
Policy.ReadWrite.AuthenticationMethod
Indisponível.
Delegado (conta pessoal da Microsoft)
Sem suporte.
Sem suporte.
Aplicativo
Policy.ReadWrite.AuthenticationMethod
Indisponível.
Importante
Em cenários delegados com contas escolares ou profissionais, o utilizador com sessão iniciada tem de ter uma função de Microsoft Entra suportada ou uma função personalizada com uma permissão de função suportada.
O Administrador de Políticas de Autenticação é a função com menos privilégios suportada para esta operação.
No corpo do pedido, forneça uma representação JSON do objeto registrationEnforcement para pedir aos utilizadores que configurem métodos de autenticação direcionados.
Imponha o registo no tempo de início de sessão. Esta propriedade pode ser utilizada para pedir aos utilizadores que configurem métodos de autenticação direcionados.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new AuthenticationMethodsPolicy
{
RegistrationEnforcement = new RegistrationEnforcement
{
AuthenticationMethodsRegistrationCampaign = new AuthenticationMethodsRegistrationCampaign
{
SnoozeDurationInDays = 1,
EnforceRegistrationAfterAllowedSnoozes = true,
State = AdvancedConfigState.Enabled,
ExcludeTargets = new List<ExcludeTarget>
{
},
IncludeTargets = new List<AuthenticationMethodsRegistrationCampaignIncludeTarget>
{
new AuthenticationMethodsRegistrationCampaignIncludeTarget
{
Id = "3ee3a9de-0a86-4e12-a287-9769accf1ba2",
TargetType = AuthenticationMethodTargetType.Group,
TargetedAuthenticationMethod = "microsoftAuthenticator",
},
},
},
},
ReportSuspiciousActivitySettings = new ReportSuspiciousActivitySettings
{
State = AdvancedConfigState.Enabled,
IncludeTarget = new IncludeTarget
{
TargetType = AuthenticationMethodTargetType.Group,
Id = "all_users",
},
VoiceReportingCode = 0,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Policies.AuthenticationMethodsPolicy.PatchAsync(requestBody);
Importante
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAuthenticationMethodsPolicy()
registrationEnforcement := graphmodels.NewRegistrationEnforcement()
authenticationMethodsRegistrationCampaign := graphmodels.NewAuthenticationMethodsRegistrationCampaign()
snoozeDurationInDays := int32(1)
authenticationMethodsRegistrationCampaign.SetSnoozeDurationInDays(&snoozeDurationInDays)
enforceRegistrationAfterAllowedSnoozes := true
authenticationMethodsRegistrationCampaign.SetEnforceRegistrationAfterAllowedSnoozes(&enforceRegistrationAfterAllowedSnoozes)
state := graphmodels.ENABLED_ADVANCEDCONFIGSTATE
authenticationMethodsRegistrationCampaign.SetState(&state)
excludeTargets := []graphmodels.ExcludeTargetable {
}
authenticationMethodsRegistrationCampaign.SetExcludeTargets(excludeTargets)
authenticationMethodsRegistrationCampaignIncludeTarget := graphmodels.NewAuthenticationMethodsRegistrationCampaignIncludeTarget()
id := "3ee3a9de-0a86-4e12-a287-9769accf1ba2"
authenticationMethodsRegistrationCampaignIncludeTarget.SetId(&id)
targetType := graphmodels.GROUP_AUTHENTICATIONMETHODTARGETTYPE
authenticationMethodsRegistrationCampaignIncludeTarget.SetTargetType(&targetType)
targetedAuthenticationMethod := "microsoftAuthenticator"
authenticationMethodsRegistrationCampaignIncludeTarget.SetTargetedAuthenticationMethod(&targetedAuthenticationMethod)
includeTargets := []graphmodels.AuthenticationMethodsRegistrationCampaignIncludeTargetable {
authenticationMethodsRegistrationCampaignIncludeTarget,
}
authenticationMethodsRegistrationCampaign.SetIncludeTargets(includeTargets)
registrationEnforcement.SetAuthenticationMethodsRegistrationCampaign(authenticationMethodsRegistrationCampaign)
requestBody.SetRegistrationEnforcement(registrationEnforcement)
reportSuspiciousActivitySettings := graphmodels.NewReportSuspiciousActivitySettings()
state := graphmodels.ENABLED_ADVANCEDCONFIGSTATE
reportSuspiciousActivitySettings.SetState(&state)
includeTarget := graphmodels.NewIncludeTarget()
targetType := graphmodels.GROUP_AUTHENTICATIONMETHODTARGETTYPE
includeTarget.SetTargetType(&targetType)
id := "all_users"
includeTarget.SetId(&id)
reportSuspiciousActivitySettings.SetIncludeTarget(includeTarget)
voiceReportingCode := int32(0)
reportSuspiciousActivitySettings.SetVoiceReportingCode(&voiceReportingCode)
requestBody.SetReportSuspiciousActivitySettings(reportSuspiciousActivitySettings)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
authenticationMethodsPolicy, err := graphClient.Policies().AuthenticationMethodsPolicy().Patch(context.Background(), requestBody, nil)
Importante
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AuthenticationMethodsPolicy authenticationMethodsPolicy = new AuthenticationMethodsPolicy();
RegistrationEnforcement registrationEnforcement = new RegistrationEnforcement();
AuthenticationMethodsRegistrationCampaign authenticationMethodsRegistrationCampaign = new AuthenticationMethodsRegistrationCampaign();
authenticationMethodsRegistrationCampaign.setSnoozeDurationInDays(1);
authenticationMethodsRegistrationCampaign.setEnforceRegistrationAfterAllowedSnoozes(true);
authenticationMethodsRegistrationCampaign.setState(AdvancedConfigState.Enabled);
LinkedList<ExcludeTarget> excludeTargets = new LinkedList<ExcludeTarget>();
authenticationMethodsRegistrationCampaign.setExcludeTargets(excludeTargets);
LinkedList<AuthenticationMethodsRegistrationCampaignIncludeTarget> includeTargets = new LinkedList<AuthenticationMethodsRegistrationCampaignIncludeTarget>();
AuthenticationMethodsRegistrationCampaignIncludeTarget authenticationMethodsRegistrationCampaignIncludeTarget = new AuthenticationMethodsRegistrationCampaignIncludeTarget();
authenticationMethodsRegistrationCampaignIncludeTarget.setId("3ee3a9de-0a86-4e12-a287-9769accf1ba2");
authenticationMethodsRegistrationCampaignIncludeTarget.setTargetType(AuthenticationMethodTargetType.Group);
authenticationMethodsRegistrationCampaignIncludeTarget.setTargetedAuthenticationMethod("microsoftAuthenticator");
includeTargets.add(authenticationMethodsRegistrationCampaignIncludeTarget);
authenticationMethodsRegistrationCampaign.setIncludeTargets(includeTargets);
registrationEnforcement.setAuthenticationMethodsRegistrationCampaign(authenticationMethodsRegistrationCampaign);
authenticationMethodsPolicy.setRegistrationEnforcement(registrationEnforcement);
ReportSuspiciousActivitySettings reportSuspiciousActivitySettings = new ReportSuspiciousActivitySettings();
reportSuspiciousActivitySettings.setState(AdvancedConfigState.Enabled);
IncludeTarget includeTarget = new IncludeTarget();
includeTarget.setTargetType(AuthenticationMethodTargetType.Group);
includeTarget.setId("all_users");
reportSuspiciousActivitySettings.setIncludeTarget(includeTarget);
reportSuspiciousActivitySettings.setVoiceReportingCode(0);
authenticationMethodsPolicy.setReportSuspiciousActivitySettings(reportSuspiciousActivitySettings);
AuthenticationMethodsPolicy result = graphClient.policies().authenticationMethodsPolicy().patch(authenticationMethodsPolicy);
Importante
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\AuthenticationMethodsPolicy;
use Microsoft\Graph\Beta\Generated\Models\RegistrationEnforcement;
use Microsoft\Graph\Beta\Generated\Models\AuthenticationMethodsRegistrationCampaign;
use Microsoft\Graph\Beta\Generated\Models\AdvancedConfigState;
use Microsoft\Graph\Beta\Generated\Models\ExcludeTarget;
use Microsoft\Graph\Beta\Generated\Models\AuthenticationMethodsRegistrationCampaignIncludeTarget;
use Microsoft\Graph\Beta\Generated\Models\AuthenticationMethodTargetType;
use Microsoft\Graph\Beta\Generated\Models\ReportSuspiciousActivitySettings;
use Microsoft\Graph\Beta\Generated\Models\IncludeTarget;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AuthenticationMethodsPolicy();
$registrationEnforcement = new RegistrationEnforcement();
$registrationEnforcementAuthenticationMethodsRegistrationCampaign = new AuthenticationMethodsRegistrationCampaign();
$registrationEnforcementAuthenticationMethodsRegistrationCampaign->setSnoozeDurationInDays(1);
$registrationEnforcementAuthenticationMethodsRegistrationCampaign->setEnforceRegistrationAfterAllowedSnoozes(true);
$registrationEnforcementAuthenticationMethodsRegistrationCampaign->setState(new AdvancedConfigState('enabled'));
$registrationEnforcementAuthenticationMethodsRegistrationCampaign->setExcludeTargets([ ]);
$includeTargetsAuthenticationMethodsRegistrationCampaignIncludeTarget1 = new AuthenticationMethodsRegistrationCampaignIncludeTarget();
$includeTargetsAuthenticationMethodsRegistrationCampaignIncludeTarget1->setId('3ee3a9de-0a86-4e12-a287-9769accf1ba2');
$includeTargetsAuthenticationMethodsRegistrationCampaignIncludeTarget1->setTargetType(new AuthenticationMethodTargetType('group'));
$includeTargetsAuthenticationMethodsRegistrationCampaignIncludeTarget1->setTargetedAuthenticationMethod('microsoftAuthenticator');
$includeTargetsArray []= $includeTargetsAuthenticationMethodsRegistrationCampaignIncludeTarget1;
$registrationEnforcementAuthenticationMethodsRegistrationCampaign->setIncludeTargets($includeTargetsArray);
$registrationEnforcement->setAuthenticationMethodsRegistrationCampaign($registrationEnforcementAuthenticationMethodsRegistrationCampaign);
$requestBody->setRegistrationEnforcement($registrationEnforcement);
$reportSuspiciousActivitySettings = new ReportSuspiciousActivitySettings();
$reportSuspiciousActivitySettings->setState(new AdvancedConfigState('enabled'));
$reportSuspiciousActivitySettingsIncludeTarget = new IncludeTarget();
$reportSuspiciousActivitySettingsIncludeTarget->setTargetType(new AuthenticationMethodTargetType('group'));
$reportSuspiciousActivitySettingsIncludeTarget->setId('all_users');
$reportSuspiciousActivitySettings->setIncludeTarget($reportSuspiciousActivitySettingsIncludeTarget);
$reportSuspiciousActivitySettings->setVoiceReportingCode(0);
$requestBody->setReportSuspiciousActivitySettings($reportSuspiciousActivitySettings);
$result = $graphServiceClient->policies()->authenticationMethodsPolicy()->patch($requestBody)->wait();
Importante
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.authentication_methods_policy import AuthenticationMethodsPolicy
from msgraph_beta.generated.models.registration_enforcement import RegistrationEnforcement
from msgraph_beta.generated.models.authentication_methods_registration_campaign import AuthenticationMethodsRegistrationCampaign
from msgraph_beta.generated.models.advanced_config_state import AdvancedConfigState
from msgraph_beta.generated.models.exclude_target import ExcludeTarget
from msgraph_beta.generated.models.authentication_methods_registration_campaign_include_target import AuthenticationMethodsRegistrationCampaignIncludeTarget
from msgraph_beta.generated.models.authentication_method_target_type import AuthenticationMethodTargetType
from msgraph_beta.generated.models.report_suspicious_activity_settings import ReportSuspiciousActivitySettings
from msgraph_beta.generated.models.include_target import IncludeTarget
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AuthenticationMethodsPolicy(
registration_enforcement = RegistrationEnforcement(
authentication_methods_registration_campaign = AuthenticationMethodsRegistrationCampaign(
snooze_duration_in_days = 1,
enforce_registration_after_allowed_snoozes = True,
state = AdvancedConfigState.Enabled,
exclude_targets = [
],
include_targets = [
AuthenticationMethodsRegistrationCampaignIncludeTarget(
id = "3ee3a9de-0a86-4e12-a287-9769accf1ba2",
target_type = AuthenticationMethodTargetType.Group,
targeted_authentication_method = "microsoftAuthenticator",
),
],
),
),
report_suspicious_activity_settings = ReportSuspiciousActivitySettings(
state = AdvancedConfigState.Enabled,
include_target = IncludeTarget(
target_type = AuthenticationMethodTargetType.Group,
id = "all_users",
),
voice_reporting_code = 0,
),
)
result = await graph_client.policies.authentication_methods_policy.patch(request_body)
Importante
Os SDKs do Microsoft Graph usam a versão v1.0 da API por padrão e não oferecem suporte a todos os tipos, propriedades e APIs disponíveis na versão beta. Para obter detalhes sobre como acessar a API beta com o SDK, consulte Usar os SDKs do Microsoft Graph com a API beta.