Skip to content

Commit 1519b88

Browse files
authored
Merge pull request #94 from KelvinTegelaar/master
[pull] master from KelvinTegelaar:master
2 parents 1593c2e + d8d9df3 commit 1519b88

29 files changed

+2153
-428
lines changed

Modules/CIPPCore/Public/Add-CIPPAzDataTableEntity.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function Add-CIPPAzDataTableEntity {
102102

103103
$propertiesToRemove = [System.Collections.Generic.List[object]]::new()
104104
foreach ($key in $SingleEnt.Keys) {
105+
if ($key -in @('RowKey', 'PartitionKey')) { continue }
105106
$newEntitySize = [System.Text.Encoding]::UTF8.GetByteCount($($newEntity | ConvertTo-Json -Compress))
106107
if ($newEntitySize -lt $MaxRowSize) {
107108
$propertySize = [System.Text.Encoding]::UTF8.GetByteCount($SingleEnt[$key].ToString())
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function Get-CIPPAlertSmtpAuthSuccess {
2+
<#
3+
.FUNCTIONALITY
4+
Entrypoint – Check sign-in logs for SMTP AUTH with success status
5+
#>
6+
[CmdletBinding()]
7+
Param (
8+
[Parameter(Mandatory = $false)]
9+
[Alias('input')]
10+
$InputValue,
11+
$TenantFilter
12+
)
13+
14+
try {
15+
# Graph API endpoint for sign-ins
16+
$uri = "https://graph.microsoft.com/v1.0/auditLogs/signIns?`$filter=clientAppUsed eq 'SMTP' and status/errorCode eq 0"
17+
18+
# Call Graph API for the given tenant
19+
$SignIns = New-GraphGetRequest -uri $uri -tenantid $TenantFilter
20+
21+
# Select only the properties you care about
22+
$AlertData = $SignIns.value | Select-Object userPrincipalName, createdDateTime, clientAppUsed, ipAddress, status
23+
24+
# Write results into the alert pipeline
25+
Write-AlertTrace -cmdletName $MyInvocation.MyCommand -tenantFilter $TenantFilter -data $AlertData
26+
27+
} catch {
28+
# Suppress errors if no data returned
29+
# Uncomment if you want explicit error logging
30+
# Write-AlertMessage -tenant $($TenantFilter) -message "Failed to query SMTP AUTH sign-ins for $($TenantFilter): $(Get-NormalizedError -message $_.Exception.message)"
31+
}
32+
}

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecOnboardTenantQueue.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ function Push-ExecOnboardTenantQueue {
364364
$Table = Get-CippTable -tablename 'templates'
365365
$ExistingTemplates = Get-CippazDataTableEntity @Table -Filter "PartitionKey eq 'StandardsTemplateV2'" | Where-Object { $_.JSON -match 'AllTenants' }
366366
foreach ($AllTenantsTemplate in $ExistingTemplates) {
367-
$object = $AllTenantesTemplate.JSON | ConvertFrom-Json
367+
$object = $AllTenantsTemplate.JSON | ConvertFrom-Json
368368
$NewExcludedTenants = [system.collections.generic.list[object]]::new()
369369
if (!$object.excludedTenants) {
370370
$object | Add-Member -MemberType NoteProperty -Name 'excludedTenants' -Value @() -Force
Lines changed: 105 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,127 @@
11
using namespace System.Net
22

33
Function Invoke-ExecExtensionMapping {
4-
<#
4+
<#
55
.FUNCTIONALITY
66
Entrypoint
77
.ROLE
88
CIPP.Extension.ReadWrite
99
#>
10-
[CmdletBinding()]
11-
param($Request, $TriggerMetadata)
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
1212

13-
$APIName = $Request.Params.CIPPEndpoint
14-
$Headers = $Request.Headers
15-
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
13+
$APIName = $Request.Params.CIPPEndpoint
14+
$Headers = $Request.Headers
15+
Write-LogMessage -headers $Headers -API $APIName -message 'Accessed this API' -Sev 'Debug'
1616

17-
$Table = Get-CIPPTable -TableName CippMapping
17+
$Table = Get-CIPPTable -TableName CippMapping
1818

19-
if ($Request.Query.List) {
20-
switch ($Request.Query.List) {
21-
'HaloPSA' {
22-
$Result = Get-HaloMapping -CIPPMapping $Table
23-
}
24-
'NinjaOne' {
25-
$Result = Get-NinjaOneOrgMapping -CIPPMapping $Table
26-
}
27-
'NinjaOneFields' {
28-
$Result = Get-NinjaOneFieldMapping -CIPPMapping $Table
29-
}
30-
'Hudu' {
31-
$Result = Get-HuduMapping -CIPPMapping $Table
32-
}
33-
'HuduFields' {
34-
$Result = Get-HuduFieldMapping -CIPPMapping $Table
35-
}
36-
'Sherweb' {
37-
$Result = Get-SherwebMapping -CIPPMapping $Table
38-
}
39-
'HaloPSAFields' {
40-
$TicketTypes = Get-HaloTicketType
41-
$Result = @{'TicketTypes' = $TicketTypes }
42-
}
43-
'PWPushFields' {
44-
$Accounts = Get-PwPushAccount
45-
$Result = @{
46-
'Accounts' = $Accounts
47-
}
48-
}
19+
if ($Request.Query.List) {
20+
switch ($Request.Query.List) {
21+
'HaloPSA' {
22+
$Result = Get-HaloMapping -CIPPMapping $Table
23+
}
24+
'NinjaOne' {
25+
$Result = Get-NinjaOneOrgMapping -CIPPMapping $Table
26+
}
27+
'NinjaOneFields' {
28+
$Result = Get-NinjaOneFieldMapping -CIPPMapping $Table
29+
}
30+
'Hudu' {
31+
$Result = Get-HuduMapping -CIPPMapping $Table
32+
}
33+
'HuduFields' {
34+
$Result = Get-HuduFieldMapping -CIPPMapping $Table
35+
}
36+
'Sherweb' {
37+
$Result = Get-SherwebMapping -CIPPMapping $Table
38+
}
39+
'HaloPSAFields' {
40+
$TicketTypes = Get-HaloTicketType
41+
$Outcomes = Get-HaloTicketOutcome
42+
$Result = @{
43+
'TicketTypes' = $TicketTypes
44+
'Outcomes' = $Outcomes
4945
}
46+
}
47+
'PWPushFields' {
48+
$Accounts = Get-PwPushAccount
49+
$Result = @{
50+
'Accounts' = $Accounts
51+
}
52+
}
5053
}
54+
}
5155

52-
try {
53-
if ($Request.Query.AddMapping) {
54-
switch ($Request.Query.AddMapping) {
55-
'Sherweb' {
56-
$Result = Set-SherwebMapping -CIPPMapping $Table -APIName $APIName -Request $Request
57-
}
58-
'HaloPSA' {
59-
$Result = Set-HaloMapping -CIPPMapping $Table -APIName $APIName -Request $Request
60-
}
61-
'NinjaOne' {
62-
$Result = Set-NinjaOneOrgMapping -CIPPMapping $Table -APIName $APIName -Request $Request
63-
Register-CIPPExtensionScheduledTasks
64-
}
65-
'NinjaOneFields' {
66-
$Result = Set-NinjaOneFieldMapping -CIPPMapping $Table -APIName $APIName -Request $Request -TriggerMetadata $TriggerMetadata
67-
Register-CIPPExtensionScheduledTasks
68-
}
69-
'Hudu' {
70-
$Result = Set-HuduMapping -CIPPMapping $Table -APIName $APIName -Request $Request
71-
Register-CIPPExtensionScheduledTasks
72-
}
73-
'HuduFields' {
74-
$Result = Set-ExtensionFieldMapping -CIPPMapping $Table -APIName $APIName -Request $Request -Extension 'Hudu'
75-
Register-CIPPExtensionScheduledTasks
76-
}
77-
}
56+
try {
57+
if ($Request.Query.AddMapping) {
58+
switch ($Request.Query.AddMapping) {
59+
'Sherweb' {
60+
$Result = Set-SherwebMapping -CIPPMapping $Table -APIName $APIName -Request $Request
61+
}
62+
'HaloPSA' {
63+
$Result = Set-HaloMapping -CIPPMapping $Table -APIName $APIName -Request $Request
64+
}
65+
'NinjaOne' {
66+
$Result = Set-NinjaOneOrgMapping -CIPPMapping $Table -APIName $APIName -Request $Request
67+
Register-CIPPExtensionScheduledTasks
68+
}
69+
'NinjaOneFields' {
70+
$Result = Set-NinjaOneFieldMapping -CIPPMapping $Table -APIName $APIName -Request $Request -TriggerMetadata $TriggerMetadata
71+
Register-CIPPExtensionScheduledTasks
7872
}
79-
$StatusCode = [HttpStatusCode]::OK
80-
} catch {
81-
$ErrorMessage = Get-CippException -Exception $_
82-
$Result = "Mapping API failed. $($ErrorMessage.NormalizedError)"
83-
Write-LogMessage -API $APIName -headers $Headers -message $Result -Sev 'Error' -LogData $ErrorMessage
84-
$StatusCode = [HttpStatusCode]::InternalServerError
73+
'Hudu' {
74+
$Result = Set-HuduMapping -CIPPMapping $Table -APIName $APIName -Request $Request
75+
Register-CIPPExtensionScheduledTasks
76+
}
77+
'HuduFields' {
78+
$Result = Set-ExtensionFieldMapping -CIPPMapping $Table -APIName $APIName -Request $Request -Extension 'Hudu'
79+
Register-CIPPExtensionScheduledTasks
80+
}
81+
}
8582
}
83+
$StatusCode = [HttpStatusCode]::OK
84+
}
85+
catch {
86+
$ErrorMessage = Get-CippException -Exception $_
87+
$Result = "Mapping API failed. $($ErrorMessage.NormalizedError)"
88+
Write-LogMessage -API $APIName -headers $Headers -message $Result -Sev 'Error' -LogData $ErrorMessage
89+
$StatusCode = [HttpStatusCode]::InternalServerError
90+
}
8691

87-
try {
88-
if ($Request.Query.AutoMapping) {
89-
switch ($Request.Query.AutoMapping) {
90-
'NinjaOne' {
91-
$Batch = [PSCustomObject]@{
92-
'NinjaAction' = 'StartAutoMapping'
93-
'FunctionName' = 'NinjaOneQueue'
94-
}
95-
$InputObject = [PSCustomObject]@{
96-
OrchestratorName = 'NinjaOneOrchestrator'
97-
Batch = @($Batch)
98-
}
99-
#Write-Host ($InputObject | ConvertTo-Json)
100-
$InstanceId = Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5 -Compress)
101-
Write-Host "Started permissions orchestration with ID = '$InstanceId'"
102-
$Result = 'AutoMapping Request has been queued. Exact name matches will appear first and matches on device names and serials will take longer. Please check the CIPP Logbook and refresh the page once complete.'
103-
}
104-
105-
}
92+
try {
93+
if ($Request.Query.AutoMapping) {
94+
switch ($Request.Query.AutoMapping) {
95+
'NinjaOne' {
96+
$Batch = [PSCustomObject]@{
97+
'NinjaAction' = 'StartAutoMapping'
98+
'FunctionName' = 'NinjaOneQueue'
99+
}
100+
$InputObject = [PSCustomObject]@{
101+
OrchestratorName = 'NinjaOneOrchestrator'
102+
Batch = @($Batch)
103+
}
104+
#Write-Host ($InputObject | ConvertTo-Json)
105+
$InstanceId = Start-NewOrchestration -FunctionName 'CIPPOrchestrator' -InputObject ($InputObject | ConvertTo-Json -Depth 5 -Compress)
106+
Write-Host "Started permissions orchestration with ID = '$InstanceId'"
107+
$Result = 'AutoMapping Request has been queued. Exact name matches will appear first and matches on device names and serials will take longer. Please check the CIPP Logbook and refresh the page once complete.'
106108
}
107-
$StatusCode = [HttpStatusCode]::OK
108-
} catch {
109-
$ErrorMessage = Get-CippException -Exception $_
110-
$Result = "Mapping API failed. $($ErrorMessage.NormalizedError)"
111-
Write-LogMessage -API $APIName -headers $Headers -message $Result -Sev 'Error' -LogData $ErrorMessage
112-
$StatusCode = [HttpStatusCode]::InternalServerError
109+
110+
}
113111
}
112+
$StatusCode = [HttpStatusCode]::OK
113+
}
114+
catch {
115+
$ErrorMessage = Get-CippException -Exception $_
116+
$Result = "Mapping API failed. $($ErrorMessage.NormalizedError)"
117+
Write-LogMessage -API $APIName -headers $Headers -message $Result -Sev 'Error' -LogData $ErrorMessage
118+
$StatusCode = [HttpStatusCode]::InternalServerError
119+
}
114120

115-
# Associate values to output bindings by calling 'Push-OutputBinding'.
116-
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
117-
StatusCode = $StatusCode
118-
Body = $Result
119-
})
121+
# Associate values to output bindings by calling 'Push-OutputBinding'.
122+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
123+
StatusCode = $StatusCode
124+
Body = $Result
125+
})
120126

121127
}

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Administration/Invoke-ExecModifyCalPerms.ps1

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

3-
Function Invoke-ExecModifyCalPerms {
3+
function Invoke-ExecModifyCalPerms {
44
<#
55
.FUNCTIONALITY
66
Entrypoint
@@ -64,6 +64,7 @@ Function Invoke-ExecModifyCalPerms {
6464
$Modification = $Permission.Modification
6565
$CanViewPrivateItems = $Permission.CanViewPrivateItems ?? $false
6666
$FolderName = $Permission.FolderName ?? 'Calendar'
67+
$SendNotificationToUser = $Permission.SendNotificationToUser ?? $false
6768

6869
Write-LogMessage -headers $Headers -API $APIName -message "Permission Level: $PermissionLevel, Modification: $Modification, CanViewPrivateItems: $CanViewPrivateItems, FolderName: $FolderName" -Sev 'Debug'
6970

@@ -76,16 +77,17 @@ Function Invoke-ExecModifyCalPerms {
7677
try {
7778
Write-LogMessage -headers $Headers -API $APIName -message "Processing target user: $TargetUser" -Sev 'Debug'
7879
$Params = @{
79-
APIName = $APIName
80-
Headers = $Headers
81-
RemoveAccess = if ($Modification -eq 'Remove') { $TargetUser } else { $null }
82-
TenantFilter = $TenantFilter
83-
UserID = $UserId
84-
folderName = $FolderName
85-
UserToGetPermissions = $TargetUser
86-
LoggingName = $TargetUser
87-
Permissions = $PermissionLevel
88-
CanViewPrivateItems = $CanViewPrivateItems
80+
APIName = $APIName
81+
Headers = $Headers
82+
RemoveAccess = if ($Modification -eq 'Remove') { $TargetUser } else { $null }
83+
TenantFilter = $TenantFilter
84+
UserID = $UserId
85+
folderName = $FolderName
86+
UserToGetPermissions = $TargetUser
87+
LoggingName = $TargetUser
88+
Permissions = $PermissionLevel
89+
CanViewPrivateItems = $CanViewPrivateItems
90+
SendNotificationToUser = $SendNotificationToUser
8991
}
9092

9193
# Write-Host "Request params: $($Params | ConvertTo-Json)"

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Email-Exchange/Administration/Invoke-ListMailboxes.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Function Invoke-ListMailboxes {
1717
# Interact with query parameters or the body of the request.
1818
$TenantFilter = $Request.Query.tenantFilter
1919
try {
20-
$Select = 'id,ExchangeGuid,ArchiveGuid,UserPrincipalName,DisplayName,PrimarySMTPAddress,RecipientType,RecipientTypeDetails,EmailAddresses,WhenSoftDeleted,IsInactiveMailbox,ForwardingSmtpAddress,DeliverToMailboxAndForward,ForwardingAddress,HiddenFromAddressListsEnabled,ExternalDirectoryObjectId,MessageCopyForSendOnBehalfEnabled,MessageCopyForSentAsEnabled,PersistedCapabilities,LitigationHoldEnabled,LitigationHoldDate,LitigationHoldDuration,ComplianceTagHoldApplied,RetentionHoldEnabled,InPlaceHolds'
20+
$Select = 'id,ExchangeGuid,ArchiveGuid,UserPrincipalName,DisplayName,PrimarySMTPAddress,RecipientType,RecipientTypeDetails,EmailAddresses,WhenSoftDeleted,IsInactiveMailbox,ForwardingSmtpAddress,DeliverToMailboxAndForward,ForwardingAddress,HiddenFromAddressListsEnabled,ExternalDirectoryObjectId,MessageCopyForSendOnBehalfEnabled,MessageCopyForSentAsEnabled,PersistedCapabilities,LitigationHoldEnabled,LitigationHoldDate,LitigationHoldDuration,ComplianceTagHoldApplied,RetentionHoldEnabled,InPlaceHolds,RetentionPolicy'
2121
$ExoRequest = @{
2222
tenantid = $TenantFilter
2323
cmdlet = 'Get-Mailbox'
@@ -76,7 +76,8 @@ Function Invoke-ListMailboxes {
7676
@{ Name = 'LicensedForLitigationHold'; Expression = { ($_.PersistedCapabilities -contains 'BPOS_S_DlpAddOn' -or $_.PersistedCapabilities -contains 'BPOS_S_Enterprise') } },
7777
ComplianceTagHoldApplied,
7878
RetentionHoldEnabled,
79-
InPlaceHolds
79+
InPlaceHolds,
80+
RetentionPolicy
8081
# This select also exists in ListUserMailboxDetails and should be updated if this is changed here
8182

8283

0 commit comments

Comments
 (0)