Skip to content

Commit 85181ac

Browse files
committed
fix support for addexconnector with limited tenants
1 parent 51c421d commit 85181ac

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Transport/Invoke-AddExConnector.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using namespace System.Net
22

3-
Function Invoke-AddExConnector {
3+
function Invoke-AddExConnector {
44
<#
55
.FUNCTIONALITY
6-
Entrypoint
6+
Entrypoint,AnyTenant
77
.ROLE
88
Exchange.Connector.ReadWrite
99
#>
@@ -19,6 +19,15 @@ Function Invoke-AddExConnector {
1919
$RequestParams = $Request.Body.PowerShellCommand | ConvertFrom-Json | Select-Object -Property * -ExcludeProperty GUID, cippConnectorType, SenderRewritingEnabled
2020
if ($RequestParams.comment) { $RequestParams.comment = Get-CIPPTextReplacement -Text $RequestParams.comment -TenantFilter $Tenant } else { $RequestParams | Add-Member -NotePropertyValue 'no comment' -NotePropertyName comment -Force }
2121
$Tenants = ($Request.Body.selectedTenants).value
22+
23+
$AllowedTenants = Test-CippAccess -Request $Request -TenantList
24+
25+
if ($AllowedTenants -ne 'AllTenants') {
26+
$AllTenants = Get-Tenants -IncludeErrors
27+
$AllowedTenantList = $AllTenants | Where-Object { $_.customerId -in $AllowedTenants }
28+
$Tenants = $Tenants | Where-Object { $_ -in $AllowedTenantList.defaultDomainName }
29+
}
30+
2231
$Result = foreach ($TenantFilter in $Tenants) {
2332
try {
2433
$null = New-ExoRequest -tenantid $TenantFilter -cmdlet "New-$($ConnectorType)connector" -cmdParams $RequestParams

0 commit comments

Comments
 (0)