Skip to content

Commit 13b772d

Browse files
authored
Merge pull request #286 from shriramnat/master
Fixing Multi Tenancy issues in Identity Module
2 parents dce3950 + 2966086 commit 13b772d

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

Identity/AzureStack.Identity.psm1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,6 @@ function Register-AzsWithMyDirectoryTenant {
345345
[ValidateNotNullOrEmpty()]
346346
[string] $DirectoryTenantName,
347347

348-
# Optional: The identifier (GUID) of the Resource Manager application. Pass this parameter to skip the need to complete the guest signup flow via the portal.
349-
[Parameter(Mandatory=$false)]
350-
[ValidateNotNullOrEmpty()]
351-
[string] $ResourceManagerApplicationId,
352-
353348
# Optional: A credential used to authenticate with Azure Stack. Must support a non-interactive authentication flow. If not provided, the script will prompt for user credentials.
354349
[Parameter()]
355350
[ValidateNotNull()]
@@ -359,6 +354,9 @@ function Register-AzsWithMyDirectoryTenant {
359354
$ErrorActionPreference = 'Stop'
360355
$VerbosePreference = 'Continue'
361356

357+
# Get the Application of Resource Manager
358+
$ResourceManagerApplicationId = $(Invoke-RestMethod "$TenantResourceManagerEndpoint/metadata/identity?api-version=2015-01-01").applicationId
359+
362360
# Install-Module AzureRm -RequiredVersion '1.2.8'
363361
Import-Module 'AzureRm.Profile' -Force -Verbose:$false 4> $null
364362
Import-Module "$PSScriptRoot\GraphAPI\GraphAPI.psm1" -Force -Verbose:$false 4> $null
@@ -405,7 +403,7 @@ function Register-AzsWithMyDirectoryTenant {
405403
# Initialize the necessary tags for the registered application
406404
if ($applicationRegistration.tags)
407405
{
408-
Update-GraphApplicationServicePrincipalTags -ApplicationId $applicationRegistration.appId -Tags $applicationRegistration.tags
406+
Update-GraphApplicationServicePrincipalTag -ApplicationId $applicationRegistration.appId -Tags $applicationRegistration.tags
409407
}
410408

411409
# Lookup the permission consent status for the application permissions (either to or from) that the registered application requires

Identity/README.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
// Place your settings in this file to overwrite the default settings
2-
{
3-
"workbench.colorTheme": "Abyss"
4-
}nstall-Module -Name 'AzureRm.Bootstrapper' -Scope CurrentUser
5-
Install-AzureRmProfile -profile '2017-03-09-profile' -Force -Scope CurrentUser
6-
Install-Module -Name AzureStack -RequiredVersion 1.2.9 -Scope CurrentUser
7-
```
1+
Instructions below are relative to the .\Identity folder of the AzureStack-Tools repo.
82

93
Then make sure the following modules are imported:
104

@@ -13,18 +7,7 @@ Import-Module ..\Connect\AzureStack.Connect.psm1
137
Import-Module ..\Identity\AzureStack.Identity.psm1
148
```
159

16-
## Getting the directory tenant identifier from the Identity System
17-
18-
This function is used to get the Directory Tenant Guid. This method works for both AAD and AD FS.
19-
20-
```powershell
21-
$directoryTenantId = Get-AzsDirectoryTenantIdentifier -Authority "<DirectoryTenantUrl>"
22-
```
23-
24-
An example of an authority for AAD is `https://login.windows.net/microsoft.onmicrosoft.com`
25-
and for AD FS is `https://adfs.local.azurestack.external/adfs`.
26-
27-
## Creating a Service Principal in a disconnected (AD FS) topology
10+
# Creating a Service Principal in a disconnected (AD FS) topology
2811

2912
You can create a Service Principal by executing the following command after importing the Identity module
3013

@@ -38,17 +21,17 @@ After the Service Principal is created, you should open your Azure Stack Portal
3821
Add-AzureRmAccount -EnvironmentName "<AzureStackEnvironmentName>" -ServicePrincipal -CertificateThumbprint $servicePrincipal.Thumbprint -ApplicationId $servicePrincipal.ApplicationId -TenantId $directoryTenantId
3922
```
4023

41-
## Enabling AAD Multi-Tenancy in Azure Stack
24+
# Enabling AAD Multi-Tenancy in Azure Stack
4225

4326
Allowing users and service principals from multiple AAD directory tenants to sign in and create resources on Azure Stack.
4427
There are two personas involved in implementing this scenario.
4528

4629
1. The Administrator of the Azure Stack installation
4730
1. The Directory Tenant Administrator of the directory that needs to be onboarded to Azure Stack
4831

49-
### Azure Stack Administrator
32+
## Azure Stack Administrator
5033

51-
#### Step 1: Onboard the Guest Directory Tenant to Azure Stack
34+
### Step 1: Onboard the Guest Directory Tenant to Azure Stack
5235

5336
This step will let Azure Resource manager know that it can accept users and service principals from the guest directory tenant.
5437

@@ -65,16 +48,11 @@ Register-AzsGuestDirectoryTenant -AdminResourceManagerEndpoint $adminARMEndpoint
6548

6649
With this step, the work of the Azure Stack administrator is done.
6750

68-
### Guest Directory Tenant Administrator
51+
## Guest Directory Tenant Administrator
6952

7053
The following steps need to be completed by the **Directory Tenant Administrator** of the directory that needs to be onboarded to Azure Stack.
7154

72-
#### Step 2: Providing UI-based consent to Azure Stack Portal and ARM
73-
74-
- This is an important step. Open up a web browser, and go to `https://portal.<region>.<domain>/guest/signup/<guestDirectoryName>`. Note that this is the directory tenant that needs to be onboarded to Azure Stack.
75-
- This will take you to an AAD sign in page where you need to enter your credentials and click on 'Accept' on the consent screen.
76-
77-
#### Step 3: Registering Azure Stack applications with the Guest Directory
55+
### Step 2: Registering Azure Stack applications with the Guest Directory
7856

7957
Execute the following cmdlet as the administrator of the directory that needs to be onboarded, replacing ```$guestDirectoryTenantName``` with your directory domain name
8058

@@ -85,3 +63,14 @@ $guestDirectoryTenantName = "<guestDirectoryTenant>.onmicrosoft.com" # this is t
8563
Register-AzsWithMyDirectoryTenant -TenantResourceManagerEndpoint $tenantARMEndpoint `
8664
-DirectoryTenantName $guestDirectoryTenantName
8765
```
66+
67+
# Getting the directory tenant identifier from the Identity System
68+
69+
This function is used to get the Directory Tenant Guid. This method works for both AAD and AD FS.
70+
71+
```powershell
72+
$directoryTenantId = Get-AzsDirectoryTenantIdentifier -Authority "<DirectoryTenantUrl>"
73+
```
74+
75+
An example of an authority for AAD is `https://login.windows.net/microsoft.onmicrosoft.com`
76+
and for AD FS is `https://adfs.local.azurestack.external/adfs`.

0 commit comments

Comments
 (0)