Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#614 from kris6673/sp-disable-basic-…
Browse files Browse the repository at this point in the history
…auth

Add disable legacy basic authentication for SharePoint standard
  • Loading branch information
KelvinTegelaar authored Feb 5, 2024
2 parents 6b24163 + aea997a commit eb8eeb0
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function Invoke-CIPPStandardDisableSharePointLegacyAuth {
<#
.FUNCTIONALITY
Internal
#>
param($Tenant, $Settings)

$CurrentInfo = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/admin/sharepoint/settings?$select=isLegacyAuthProtocolsEnabled' -tenantid $Tenant -AsApp $true

If ($Settings.remediate) {

if ($CurrentInfo.isLegacyAuthProtocolsEnabled) {
try {
$body = '{"isLegacyAuthProtocolsEnabled": "false"}'
$null = New-GraphPostRequest -tenantid $tenant -Uri 'https://graph.microsoft.com/beta/admin/sharepoint/settings' -AsApp $true -Type patch -Body $body -ContentType 'application/json'
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Disabled SharePoint basic authentication' -sev Info
$CurrentInfo.isLegacyAuthProtocolsEnabled = $false
} catch {
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to disable SharePoint basic authentication. Error: $($_.exception.message)" -sev Error
}
} else {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'SharePoint basic authentication is already disabled' -sev Info
}
}
if ($Settings.alert) {

if ($CurrentInfo.isLegacyAuthProtocolsEnabled) {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'SharePoint basic authentication is enabled' -sev Alert
} else {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'SharePoint basic authentication is disabled' -sev Info
}
}
if ($Settings.report) {

Add-CIPPBPAField -FieldName 'SharePointLegacyAuthEnabled' -FieldValue [bool]$CurrentInfo.isLegacyAuthProtocolsEnabled -StoreAs bool -Tenant $tenant
}
}

0 comments on commit eb8eeb0

Please sign in to comment.