Disable “Require Use Remote Interfaces permission” using power shell
-
04-10-2020 - |
Вопрос
I want to disable "Require Use Remote Interfaces permission" of web application using power shell script.
Решение
I was not able to find any way to do that using the standard either PowerShell SnapIn or the CSOM/REST, so i looked under the covers. From tracing the code in the code-behind of that AuthenticationPage in the CA, here is a script that does decent job via Reflection.
Param(
[parameter(Mandatory=$true,ValueFromPipeline=$true)]
[Microsoft.SharePoint.Administration.SPWebApplication] $webapp,
[Parameter(Mandatory=$true)]
[Microsoft.SharePoint.Administration.SPUrlZone] $zone,
[Parameter(Mandatory=$true)]
[bool] $RequiresUseRemoteAPIsPermission
)
[Microsoft.SharePoint.Administration.SPIisSettings] $newIisSettings = New-Object Microsoft.SharePoint.Administration.SPIisSettings
[Microsoft.SharePoint.Administration.SPIisSettings] $originalSettings = $webapp.IisSettings[$zone]
$nonPublicInstanceMethodBindingFlags = [Reflection.BindingFlags] "NonPublic,Instance"
$copyFromMethod = $newIisSettings.GetType().GetMethod("CopyFrom", $nonPublicInstanceMethodBindingFlags)
$copyFromMethod.Invoke($newIisSettings, $originalSettings)
$newIisSettings.ClientObjectModelRequiresUseRemoteAPIsPermission = $RequiresUseRemoteAPIsPermission
$UpdateAuthenticationSettingsMethod = $webapp.GetType().GetMethods($nonPublicInstanceMethodBindingFlags) |
?{ $_.Name -eq 'UpdateAuthenticationSettings' -and $_.GetParameters().Count -eq 2 }
$UpdateAuthenticationSettingsMethod.Invoke($webapp, @($zone, $newIisSettings));
This PowerShell script can only execute on the SharePoint server itself with Microsoft.SharePoint.PowerShell Snap-In running but it'll do the trick.
Не связан с sharepoint.stackexchange