Skip to content

Commit a8d45c2

Browse files
authored
Merge pull request #305 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 02c6298 + 888cce4 commit a8d45c2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecAddTenant.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ function Invoke-ExecAddTenant {
2222
# Check if tenant already exists
2323
$ExistingTenant = Get-CIPPAzDataTableEntity @TenantsTable -Filter "PartitionKey eq 'Tenants' and RowKey eq '$tenantId'"
2424

25-
if ($ExistingTenant) {
25+
if ($tenantId -eq $env:TenantID) {
26+
# If the tenant is the partner tenant, return an error because you cannot add the partner tenant as direct tenant
27+
$Results = @{'message' = 'You cannot add the partner tenant as a direct tenant. Please connect the tenant using the "Connect to Partner Tenant" option. '; 'severity' = 'error'; }
28+
} elseif ($ExistingTenant) {
2629
# Update existing tenant
2730
$ExistingTenant.delegatedPrivilegeStatus = 'directTenant'
2831
Add-CIPPAzDataTableEntity @TenantsTable -Entity $ExistingTenant -Force | Out-Null

Modules/CIPPCore/Public/GraphHelper/Get-GraphToken.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Get-GraphToken($tenantid, $scope, $AsApp, $AppID, $AppSecret, $refreshT
2121
$TenantsTable = Get-CippTable -tablename 'Tenants'
2222
$Filter = "PartitionKey eq 'Tenants' and delegatedPrivilegeStatus eq 'directTenant'"
2323
$ClientType = Get-CIPPAzDataTableEntity @TenantsTable -Filter $Filter | Where-Object { $_.customerId -eq $tenantid -or $_.defaultDomainName -eq $tenantid }
24-
if ($clientType.delegatedPrivilegeStatus -eq 'directTenant') {
24+
if ($tenantid -ne $env:TenantID -and $clientType.delegatedPrivilegeStatus -eq 'directTenant') {
2525
Write-Host "Using direct tenant refresh token for $($clientType.customerId)"
2626
$ClientRefreshToken = Get-Item -Path "env:\$($clientType.customerId)" -ErrorAction SilentlyContinue
2727
$refreshToken = $ClientRefreshToken.Value

0 commit comments

Comments
 (0)