애플리케이션에 대한 사용자 및 그룹 할당 관리

이 문서에서는 PowerShell을 사용하여 Microsoft Entra ID의 엔터프라이즈 애플리케이션에 사용자 및 그룹을 할당하는 방법을 보여 줍니다. 애플리케이션에 사용자를 할당하면 쉽게 액세스할 수 있도록 애플리케이션이 사용자의 내 앱 포털에 표시됩니다. 애플리케이션이 앱 역할을 노출하는 경우 사용자에게 특정 앱 역할을 할당할 수도 있습니다.

애플리케이션에 그룹을 할당하면 그룹의 사용자만 액세스할 수 있습니다. 할당은 중첩된 그룹으로 연속되지 않습니다.

그룹 기반 할당에는 Microsoft Entra ID P1 또는 P2 버전이 필요합니다. 그룹 기반 할당은 SecurityEnabled 설정이 True로 설정된 보안 그룹 및 Microsoft 365 그룹에 대해서만 지원됩니다. 중첩된 그룹 멤버 자격은 현재 지원되지 않습니다. 이 문서에서 설명하는 기능에 대한 추가 라이선스 요구 사항은 Microsoft Entra 가격 책정 페이지를 참조하세요.

더 많은 제어를 위해 특정 유형의 엔터프라이즈 애플리케이션을 사용자 할당이 필요하도록 구성할 수 있습니다. 앱에 대한 사용자 할당을 요구하는 방법에 대한 자세한 내용은 애플리케이션에 대한 액세스 관리를 참조하세요.

필수 조건

엔터프라이즈 애플리케이션에 사용자를 할당하려면 다음이 필요합니다.

  • 활성 구독이 있는 Microsoft Entra 계정. 계정이 없다면 무료로 만들 수 있습니다.
  • 다음 역할 중 하나: 전역 관리자, 클라우드 애플리케이션 관리자, 애플리케이션 관리자 또는 서비스 주체의 소유자.
  • 그룹 기반 할당을 위한 Microsoft Entra ID P1 또는 P2. 이 문서에서 설명하는 기능에 대한 추가 라이선스 요구 사항은 Microsoft Entra 가격 책정 페이지를 참조하세요.

이 문서의 단계는 시작하는 포털에 따라 약간 다를 수 있습니다.

Microsoft Entra 관리 센터를 사용하여 애플리케이션에 사용자 및 그룹 할당

사용자 또는 그룹 계정을 엔터프라이즈 애플리케이션에 할당하려면 다음을 수행합니다.

  1. 최소한 클라우드 애플리케이션 관리자Microsoft Entra 관리 센터에 로그인합니다.

  2. ID>애플리케이션>엔터프라이즈 애플리케이션>모든 애플리케이션으로 이동합니다.

  3. 검색 상자에서 기존 애플리케이션 이름을 입력한 다음, 검색 결과에서 애플리케이션을 선택합니다.

  4. 사용자 및 그룹을 선택한 다음 사용자/그룹 추가를 선택합니다.

    Assign user account to an application in your Microsoft Entra tenant.

  5. 할당 추가 창의 사용자 및 그룹 아래에서 선택된 항목 없음을 선택합니다.

  6. 애플리케이션에 할당하려는 사용자 또는 그룹을 검색하여 선택합니다. 예를 들어 contosouser1@contoso.com 또는 contosoteam1@contoso.com입니다.

  7. 선택을 선택합니다.

  8. 역할 선택에서 사용자 또는 그룹에 할당할 역할을 선택합니다. 아직 역할을 정의하지 않은 경우 기본 역할은 기본 액세스입니다.

  9. 할당 추가 창에서 할당을 선택하여 애플리케이션에 사용자 또는 그룹을 할당합니다.

애플리케이션에서 사용자 및 그룹 할당 취소

  1. 애플리케이션에 사용자 및 그룹 할당 섹션의 단계에 따라 사용자 및 그룹 창으로 이동합니다.
  2. 애플리케이션에서 할당을 취소하려는 사용자 또는 그룹을 검색하고 선택합니다.
  3. 애플리케이션에서 사용자 또는 그룹 할당을 취소하려면 제거를 선택합니다.

Azure AD PowerShell을 사용하여 애플리케이션에 사용자 및 그룹 할당

  1. 관리자 권한 Windows PowerShell 명령 프롬프트를 엽니다.

  2. Connect-AzureAD를 실행하고 최소한 클라우드 애플리케이션 관리자로 로그인합니다.

  3. 다음 스크립트를 사용하여 애플리케이션에 사용자 및 역할을 할당합니다.

    # Assign the values to the variables
    $username = "<Your user's UPN>"
    $app_name = "<Your App's display name>"
    $app_role_name = "<App role display name>"
    
    # Get the user to assign, and the service principal for the app to assign to
    $user = Get-AzureADUser -ObjectId "$username"
    $sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'"
    $appRole = $sp.AppRoles | Where-Object { $_.DisplayName -eq $app_role_name }
    
    # Assign the user to the app role
    New-AzureADUserAppRoleAssignment -ObjectId $user.ObjectId -PrincipalId $user.ObjectId -ResourceId $sp.ObjectId -Id $appRole.Id
    

그룹을 엔터프라이즈 앱에 할당하려면 Get-AzureADUserGet-AzureADGroup으로 바꾸고 New-AzureADUserAppRoleAssignmentNew-AzureADGroupAppRoleAssignment로 바꿉어야 합니다.

애플리케이션 역할에 그룹을 할당하는 방법에 대한 자세한 내용은 New-AzureADGroupAppRoleAssignment에 대한 설명서를 참조하세요.

예시

이 예제에서는 PowerShell을 사용하여 사용자 Britta Simon을 Microsoft Workplace Analytics 애플리케이션에 할당합니다.

  1. PowerShell에서 변수 $username, app_name $ 및 $app_role_name에 해당 값을 할당합니다.

    # Assign the values to the variables
    $username = "britta.simon@contoso.com"
    $app_name = "Workplace Analytics"
    
  2. 이 예제에서는 Britta Simon에 할당하려는 애플리케이션 역할의 정확한 이름을 모릅니다. 다음 명령을 실행하여 사용자 UPN 및 서비스 주체 표시 이름으로 사용자($user) 및 서비스 주체($sp)를 가져옵니다.

    # Get the user to assign, and the service principal for the app to assign to
    $user = Get-AzureADUser -ObjectId "$username"
    $sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'"
    
  3. 명령 $sp.AppRoles를 실행하여 Workplace Analytics 애플리케이션에 대해 사용할 수 있는 역할을 표시합니다. 이 예제에서는 Britta Simon을 Analyst(제한된 액세스) 역할에 할당하려고 합니다. Shows the roles available to a user using Workplace Analytics Role

  4. 역할 이름을 $app_role_name 변수에 할당합니다.

    # Assign the values to the variables
    $app_role_name = "Analyst (Limited access)"
    $appRole = $sp.AppRoles | Where-Object { $_.DisplayName -eq $app_role_name }
    
  5. 다음 명령을 실행하여 앱 역할에 사용자를 할당합니다.

    # Assign the user to the app role
    New-AzureADUserAppRoleAssignment -ObjectId $user.ObjectId -PrincipalId $user.ObjectId -ResourceId $sp.ObjectId -Id $appRole.Id
    

Azure AD PowerShell을 사용하여 애플리케이션에서 사용자 및 그룹 할당 취소

  1. 관리자 권한 Windows PowerShell 명령 프롬프트를 엽니다.

  2. Connect-AzureAD를 실행하고 최소한 클라우드 애플리케이션 관리자로 로그인합니다.

  3. 다음 스크립트를 사용하여 애플리케이션에 사용자 및 역할을 제거합니다.

    # Store the proper parameters
    $user = get-azureaduser -ObjectId <objectId>
    $spo = Get-AzureADServicePrincipal -ObjectId <objectId>
    
    #Get the ID of role assignment 
    $assignments = Get-AzureADServiceAppRoleAssignment -ObjectId $spo.ObjectId | Where {$_.PrincipalDisplayName -eq $user.DisplayName}
    
    #if you run the following, it will show you what is assigned what
    $assignments | Select *
    
    #To remove the App role assignment run the following command.
    Remove-AzureADServiceAppRoleAssignment -ObjectId $spo.ObjectId -AppRoleAssignmentId $assignments[assignment number].ObjectId
    

Azure AD PowerShell을 사용하여 애플리케이션에 할당된 모든 사용자 제거

다음 스크립트를 사용하여 애플리케이션에 할당된 모든 사용자 및 그룹을 제거합니다.

#Retrieve the service principal object ID.
$app_name = "<Your App's display name>"
$sp = Get-AzureADServicePrincipal -Filter "displayName eq '$app_name'"
$sp.ObjectId

# Get Service Principal using objectId
$sp = Get-AzureADServicePrincipal -ObjectId "<ServicePrincipal objectID>"

# Get Azure AD App role assignments using objectId of the Service Principal
$assignments = Get-AzureADServiceAppRoleAssignment -ObjectId $sp.ObjectId -All $true

# Remove all users and groups assigned to the application
$assignments | ForEach-Object {
    if ($_.PrincipalType -eq "User") {
        Remove-AzureADUserAppRoleAssignment -ObjectId $_.PrincipalId -AppRoleAssignmentId $_.ObjectId
    } elseif ($_.PrincipalType -eq "Group") {
        Remove-AzureADGroupAppRoleAssignment -ObjectId $_.PrincipalId -AppRoleAssignmentId $_.ObjectId
    }
}

Microsoft Graph PowerShell을 사용하여 애플리케이션에 사용자 및 그룹 할당

  1. 관리자 권한 Windows PowerShell 명령 프롬프트를 엽니다.
  2. Connect-MgGraph -Scopes "Application.ReadWrite.All", "Directory.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"를 실행하고 최소한 클라우드 애플리케이션 관리자로 로그인합니다.
  3. 다음 스크립트를 사용하여 애플리케이션에 사용자 및 역할을 할당합니다.

# Assign the values to the variables

$userId = "<Your user's ID>"
$app_name = "<Your App's display name>"
$app_role_name = "<App role display name>"
$sp = Get-MgServicePrincipal -Filter "displayName eq '$app_name'"

# Get the user to assign, and the service principal for the app to assign to

$params = @{
    "PrincipalId" =$userId
    "ResourceId" =$sp.Id
    "AppRoleId" =($sp.AppRoles | Where-Object { $_.DisplayName -eq $app_role_name }).Id
    }

# Assign the user to the app role

New-MgUserAppRoleAssignment -UserId $userId -BodyParameter $params |
    Format-List Id, AppRoleId, CreationTime, PrincipalDisplayName,
    PrincipalId, PrincipalType, ResourceDisplayName, ResourceId

Microsoft Graph PowerShell을 사용하여 애플리케이션에서 사용자 및 그룹 할당 취소

  1. 관리자 권한 Windows PowerShell 명령 프롬프트를 엽니다.
  2. Connect-MgGraph -Scopes "Application.ReadWrite.All", "Directory.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"를 실행하고 최소한 클라우드 애플리케이션 관리자로 로그인합니다. 다음 스크립트를 사용하여 애플리케이션에 사용자 및 역할을 제거합니다.

# Get the user and the service principal

$user = Get-MgUser -UserId <userid>
$spo = Get-MgServicePrincipal -ServicePrincipalId <ServicePrincipalId>

# Get the Id of the role assignment

$assignments = Get-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $spo.Id | Where {$_.PrincipalDisplayName -eq $user.DisplayName}

# if you run the following, it will show you the list of users assigned to the application

$assignments | Select *

# To remove the App role assignment run the following command.

Remove-MgServicePrincipalAppRoleAssignedTo -AppRoleAssignmentId  '<AppRoleAssignment-id>' -ServicePrincipalId $spo.Id

Microsoft Graph PowerShell을 사용하여 애플리케이션에 할당된 모든 사용자 및 그룹 제거

다음 스크립트를 사용하여 애플리케이션에 할당된 모든 사용자 및 그룹을 제거합니다.

$assignments | ForEach-Object {
    if ($_.PrincipalType -in ("user", "Group")) {
        Remove-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $Sp.Id -AppRoleAssignmentId $_.Id  }
}

Microsoft Graph API를 사용하여 애플리케이션에 사용자 및 그룹 할당

  1. 사용자와 그룹을 애플리케이션에 할당하려면 최소한 클라우드 애플리케이션 관리자Graph 탐색기에 로그인합니다.

    다음 권한에 동의해야 합니다.

    Application.ReadWrite.All, Directory.ReadWrite.All. AppRoleAssignment.ReadWrite.All

    앱 역할 할당을 부여하려면 다음 세 개의 식별자가 필요합니다.

    • principalId: 앱 역할을 할당할 사용자 또는 그룹의 ID
    • resourceId: 앱 역할을 정의하는 Resource ServicePrincipal의 ID입니다.
    • appRoleId: 사용자 또는 그룹에 할당할 appRole(리소스 서비스 주체에 정의됨)의 ID
  2. 엔터프라이즈 애플리케이션을 가져옵니다. DisplayName을 기준으로 필터링합니다.

    GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=displayName eq '{appDisplayName}'
    

    응답 본문에서 다음 값을 기록합니다.

    • 엔터프라이즈 애플리케이션의 개체 ID
    • 사용자에게 할당하는 appRoleId입니다. 애플리케이션에서 역할을 노출하지 않으면 사용자에게 기본 액세스 역할이 할당됩니다.
  3. 사용자의 보안 주체 이름을 기준으로 필터링하여 사용자를 가져옵니다. 사용자의 개체 ID를 기록합니다.

    GET https://graph.microsoft.com/v1.0/users/{userPrincipalName}
    
  4. 애플리케이션에 사용자를 할당하세요.

    POST https://graph.microsoft.com/v1.0/servicePrincipals/{resource-servicePrincipal-id}/appRoleAssignedTo
    
    {
    "principalId": "33ad69f9-da99-4bed-acd0-3f24235cb296",
    "resourceId": "9028d19c-26a9-4809-8e3f-20ff73e2d75e",
    "appRoleId": "ef7437e6-4f94-4a0a-a110-a439eb2aa8f7"
    }
    

    이 예제에서 resource-servicePrincipal-id와 resourceId는 모두 엔터프라이즈 애플리케이션을 나타냅니다.

Microsoft Graph API를 사용하여 애플리케이션에서 사용자 및 그룹 할당 취소

애플리케이션에서 사용자 및 그룹의 할당을 취소하려면 다음 쿼리를 실행합니다.

  1. 엔터프라이즈 애플리케이션을 가져옵니다. displayName을 기준으로 필터링합니다.

    GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=displayName eq '{appDisplayName}'
    
  2. 애플리케이션에 대한 appRoleAssignments 목록을 가져옵니다.

    GET https://graph.microsoft.com/v1.0/servicePrincipals/{id}/appRoleAssignedTo
    
  3. appRoleAssignment ID를 지정하여 appRoleAssignments를 제거합니다.

    DELETE https://graph.microsoft.com/v1.0/servicePrincipals/{resource-servicePrincipal-id}/appRoleAssignedTo/{appRoleAssignment-id}
    

다음 단계