Skip to content

Commit

Permalink
Add ExecDeleteGDAPRoleMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Aug 8, 2023
1 parent 297d39b commit dc3325b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ExecDeleteGDAPRoleMapping/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
}
26 changes: 26 additions & 0 deletions ExecDeleteGDAPRoleMapping/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using namespace System.Net

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
$Table = Get-CIPPTable -TableName 'GDAPRoles'

Write-Host $Table
try {
$Filter = "PartitionKey eq 'Roles' and RowKey eq '{0}'" -f $Request.Query.GroupId
$Entity = Get-AzDataTableEntity @Table -Filter $Filter
Remove-AzDataTableEntity @Table -Entity $Entity
$Results = [pscustomobject]@{'Results' = 'Success. GDAP relationship mapping deleted' }
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "GDAP relationship mapping deleted for $($Request.Query.GroupId)" -Sev 'Info'

} catch {
$Results = [pscustomobject]@{'Results' = "Failed. $($_.Exception.Message)" }
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $Results
})

0 comments on commit dc3325b

Please sign in to comment.