Skip to content

Commit

Permalink
* Imported other ps1 file
Browse files Browse the repository at this point in the history
* fixed bugs in helper functions
  • Loading branch information
marvinbuss committed Feb 10, 2021
1 parent 1619181 commit 51a0642
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
4 changes: 4 additions & 0 deletions code/aadScim/DatabricksScimSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ param (
$GroupIdList
)

# Import Helper Functions
Write-Host "Importing Helper Functions"
. "$PSScriptRoot\Helper.ps1"

# Authentication and get AAD Token
Write-Host "Logging in and getting AAD Token"
Get-AadToken `
Expand Down
33 changes: 21 additions & 12 deletions code/aadScim/Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ function Test-Connection {
# Set body for REST call
Write-Verbose "Setting body for REST call"
$body = @{
# 'templateId' = 'dataBricks'
'templateId' = 'dataBricks'
'useSavedCredentials' = 'false'
'credentials' = @(
@{
Expand Down Expand Up @@ -518,7 +518,7 @@ function Save-ProvisioningCredentials {
Function expects a notification email address to which messages are sent, if there are synchronization issues.
.EXAMPLE
Test-Connection -ObjectId '<your-service-principal-object-id>' -JobId '<your-synchronisation-job-id>' -DatabricksInstanceName '<your-databricks-instance-name>' -DatabricksPatToken '<your-databricks-pat-token>' -NotificationEmail '<your-notification-email>'
Save-ProvisioningCredentials -ObjectId '<your-service-principal-object-id>' -JobId '<your-synchronisation-job-id>' -DatabricksInstanceName '<your-databricks-instance-name>' -DatabricksPatToken '<your-databricks-pat-token>' -NotificationEmail '<your-notification-email>'
.NOTES
Author: Marvin Buss
Expand Down Expand Up @@ -575,10 +575,7 @@ function Save-ProvisioningCredentials {
},
@{
'key' = 'SyncNotificationSettings'
'value' = @{
'Enabled' = 'true'
'Recipients' = "${NotificationEmail}"
}
'value' = "{`"Enabled`":true,`"Recipients`":`"${NotificationEmail}`"}"
},
@{
'key' = 'SyncAll'
Expand Down Expand Up @@ -753,7 +750,7 @@ function Start-SynchronisationJob {
Write-Verbose "Defining parameters for pscore method"
$parameters = @{
'Uri' = $graphApiUri
'Method' = 'Put'
'Method' = 'Post'
'Headers' = $headers
'ContentType' = 'application/json'
}
Expand Down Expand Up @@ -907,7 +904,7 @@ function New-ScimSetup {
[String]
$NotificationEmail,

[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[String[]]
$GroupIdList
Expand All @@ -921,6 +918,10 @@ function New-ScimSetup {
$objectId = New-DatabricksEnterpriseApplication `
-DatabricksWorkspaceName $databricksWorkspaceName

# Sleep for 5 Seconds
Write-Verbose "Sleeping for 5 seconds"
Start-Sleep -Seconds 5

# Get Synchronization Template
Write-Verbose "Getting Synchronization Template"
Get-SynchronisationTemplate `
Expand Down Expand Up @@ -951,7 +952,7 @@ function New-ScimSetup {
Write-Verbose "Adding Group Assignment"
foreach ($groupId in $GroupIdList) {
New-GroupAssignment `
-ObjectId $ObjectId `
-ObjectId $objectId `
-GroupId $groupId
}

Expand All @@ -961,10 +962,18 @@ function New-ScimSetup {
-ObjectId $objectId `
-JobId $jobId

# Get Provisioning Logs
Write-Host "Getting Provisioning Logs"
$provisioningLogs = Get-ProvisioningAuditLogs `
-ObjectId $objectId `
-JobId $jobId

Write-Host "Provisioning Logs: ${provisioningLogs}"

return $objectId, $jobId
}

function New-GroupAssignment {
function New-GroupListAssignment {
<#
.SYNOPSIS
Assigns AAD groups to the enterprise application to give them access to the Databricks workspace.
Expand All @@ -985,7 +994,7 @@ function New-GroupAssignment {
Function expects a list of group object ids which is granted access to the Databricks workspace via SCIM.
.EXAMPLE
New-GroupAssignment -ObjectId '<your-service-principal-object-id>' -JobId '<your-job-id>' -GroupIdList @('<your-group-id-1>', '<your-group-id-2>')
New-GroupListAssignment -ObjectId '<your-service-principal-object-id>' -JobId '<your-job-id>' -GroupIdList @('<your-group-id-1>', '<your-group-id-2>')
.NOTES
Author: Marvin Buss
Expand Down Expand Up @@ -1017,7 +1026,7 @@ function New-GroupAssignment {
foreach ($groupId in $GroupIdList) {
New-GroupAssignment `
-ObjectId $ObjectId `
-GroupId $GroupId
-GroupId $groupId
}

# Start Synchronisation Job
Expand Down

0 comments on commit 51a0642

Please sign in to comment.