อาการ
หลังจากที่คุณติดตั้งการอัปเดตความปลอดภัยของ๒๐๑๘กันยายนของ .Net frameworkเพื่อแก้ไขการอัปเดตCVE-2018-8421 (ช่องโหว่การดำเนินการโค้ดระยะไกลของ .net Framework) การทำงานของเวิร์กโฟลว์ที่ไม่อยู่ในกล่องของ SharePoint จะหยุดทำงาน เมื่อปัญหานี้เกิดขึ้นรายการข้อผิดพลาดที่คล้ายกับต่อไปนี้ถูกบันทึกไว้:
<Date> <Time> w3wp.exe (0x1868) 0x22FC SharePoint Foundation Workflow Infrastructure 72fs Unexpected RunWorkflow: Microsoft.SharePoint.SPException: <Error><CompilerError Line="-1" Column="-1" Text="Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file." /><CompilerError Line="-1" Column="-1" Text="Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file." /><CompilerError Line="-1" Column="-1" Text="Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file." /><CompilerError Line="-1" Column="-1" Text="Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file." /><CompilerError Line="-1" Column="-1" Text="Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file." /><CompilerError Line="-1" Column="-1" Text="Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file." /><CompilerError Line="-1" Column="-1" Text="Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file." /><CompilerError Line="-1" Column="-1"…
รายการข้อผิดพลาดแนะนำว่าCodeDom CodeBinaryOperatorExpressionจะไม่รวมอยู่ในชนิดที่ได้รับอนุญาต
สำหรับข้อมูลเพิ่มเติมเกี่ยวกับการอัปเดตความปลอดภัยของ .NET ของเดือนกันยายนไปที่หน้าบล็อกของ Microsoft .net นี้
สาเหตุ
เวิร์กโฟลว์มูลฐาน (WF) จะเรียกใช้เวิร์กโฟลว์เฉพาะเมื่อชนิดและแอสเซมบลีที่อ้างถึงทั้งหมดได้รับอนุญาตในไฟล์ web.config (หรือเพิ่มอย่างชัดเจนผ่านทางโค้ด) ในแผนภูมิต่อไปนี้:
<configuration>
<System.Workflow.ComponentModel.WorkflowCompiler>
<authorizedTypes>
<targetFx>
อย่างไรก็ตามหลังจากการอัปเดตบางชนิดที่ใช้โดยเวิร์กโฟลว์การออกจากกล่องของ SharePoint ที่ไม่จำเป็นต้องใช้ก่อนหน้านี้
การแก้ไข
เมื่อต้องการแก้ไขปัญหานี้ให้ใช้การอัปเดตความปลอดภัยและ nonsecurity ที่เหมาะสมจากบทความฐานความรู้ต่อไปนี้:
๔๔๖๑๕๐๑ คำอธิบายของการอัปเดตความปลอดภัยสำหรับ SharePoint Enterprise Server ๒๐๑๖:13 พฤศจิกายน๒๐๑๘ ๔๔๖๑๕๐๘พฤศจิกายน 13, ๒๐๑๘, การอัปเดตที่สะสมสำหรับ SharePoint Foundation ๒๐๑๓ (KB4461508) ๔๔๖๑๕๑๐พฤศจิกายน 13, ๒๐๑๘, การอัปเดตที่สะสมสำหรับ SharePoint Enterprise Server ๒๐๑๓ (KB4461510) ๔๐๑๑๗๑๓พฤศจิกายน 13, ๒๐๑๘, การอัปเดตสำหรับ SharePoint Foundation ๒๐๑๐ (KB4011713) ๔๔๖๑๕๒๘พฤศจิกายน 13, ๒๐๑๘, การอัปเดตที่สะสมสำหรับ SharePoint Server ๒๐๑๐ (KB4461528)
หมายเหตุ
-
หลังจากติดตั้งการอัปเดตตัวช่วยสร้างการกำหนดค่าผลิตภัณฑ์ SharePoint จะต้องถูกเรียกใช้สำหรับการแก้ไขเพื่อให้สามารถนำไปใช้ได้อย่างเต็มรูปแบบ
-
การกระทำบางอย่างของบริษัทอื่นหรือเวิร์กโฟลว์แบบกำหนดเองอาจมีการอ้างอิงเพิ่มเติม ถ้าคุณพบลักษณะการทำงานที่คล้ายกับปัญหานี้แต่ไม่ได้กล่าวถึงในบทความนี้โปรดปรึกษานักพัฒนาการดำเนินการเวิร์กโฟลว์สำหรับความช่วยเหลือ
วิธีแก้ไขปัญหาชั่วคราว
เมื่อต้องการแก้ไขปัญหานี้ให้เพิ่มชนิดที่จำเป็นลงในไฟล์ web.config ของแอปพลิเคชันทั้งหมดอย่างชัดเจน แม้ว่าจะมีขั้นตอนด้วยตนเองเราขอแนะนำให้คุณใช้วิธีการสคริปต์
เมื่อต้องการแก้ปัญหานี้ให้เพิ่มชนิดที่จำเป็นลงในไฟล์ web.config ของแอปพลิเคชันทั้งหมดอย่างชัดเจน
สำหรับ SharePoint ๒๐๑๓และเวอร์ชันที่ใหม่กว่า
สำหรับ SharePoint ๒๐๑๓และเวอร์ชันที่ใหม่กว่าให้เพิ่มบรรทัดต่อไปนี้:
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeBinaryOperatorExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePrimitiveExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodInvokeExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeFieldReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeThisReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePropertyReferenceExpression" Authorized="True" />
สำหรับ SharePoint เวอร์ชันก่อนหน้า SharePoint ๒๐๑๓
สำหรับ SharePoint เวอร์ชันก่อนหน้า๒๐๑๓ให้เพิ่มบรรทัดต่อไปนี้แทน:
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeBinaryOperatorExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePrimitiveExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodInvokeExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeFieldReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeThisReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePropertyReferenceExpression" Authorized="True" />
เราขอแนะนำให้คุณเรียกใช้สคริปต์ต่อไปนี้แทนที่จะปรับเปลี่ยนไฟล์ที่มีอยู่โดยตรง
บันทึกย่อกลไกจัดการเวิร์กโฟลว์ของบริษัทอื่นบางโปรแกรมอาจจำเป็นต้องเพิ่มชนิดพิเศษ ถ้าเป็นกรณีนี้ให้ติดต่อผู้จำหน่ายของคุณสำหรับข้อมูลเกี่ยวกับชนิดที่จำเป็นแล้วปรับสคริปต์ให้สอดคล้องกัน
สคริปต์ต่อไปนี้จะเปลี่ยนแปลง web.config สำหรับแอปพลิเคชันบนเว็บทั้งหมดเพื่อเพิ่มรายการที่จำเป็น สคริปต์นี้จะเพิ่มชนิดเหล่านี้สำหรับแอปพลิเคชันบนเว็บที่มีอยู่และสำหรับแอปพลิเคชันที่สร้างขึ้นหลังจากที่สคริปต์ทำงาน สคริปต์ควรจะเรียกใช้เพียงครั้งเดียวบนเซิร์ฟเวอร์ส่วนหน้าของเว็บในฟาร์ม (จะอัปเดตระเบียนทั้งหมด)
<#
This script adds the entries to all web.config files for all web applications in the farm.
Run this script as Farm Administrator in one of the WFEs.
This script has to run only one time.
SUMMARY:
This script uses the native SharePoint SPWebConfigModification API to deploy new updates to the web.config file for each web application on each server in the farm. Servers that are added at a later date will also get the updates applied because the API configuration is persisted in the config database. This API does not update the web.config for the central administration web application.
If you are running workflows on the central admin web application, you will have to manually update the web.config by using the steps in the referenced blog.
==============================================================
#>
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | Out-Null
function Add-CodeDomAuthorizedType
{
<#
.Synopsis
Adds the necessary authorizedType elements to all web.config files for all non-central admin web applications
.DESCRIPTION
Adds the necessary authorizedType elements to all web.config files for all non-central admin web applications
.EXAMPLE
Add-CodeDomAuthorizedType
#>
[CmdletBinding()]
param
(
)
begin
{
$farmMajorVersion = (Get-SPFarm -Verbose:$false ).BuildVersion.Major
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$typeNames = @( "CodeBinaryOperatorExpression", "CodePrimitiveExpression", "CodeMethodInvokeExpression", "CodeMethodReferenceExpression", "CodeFieldReferenceExpression","CodeThisReferenceExpression", "CodePropertyReferenceExpression")
}
process
{
if( @($contentService.WebConfigModifications | ? { $_.Name -eq "NetFrameworkAuthorizedTypeUpdate" }).Count -gt 0 )
{
Write-Warning "Existing NetFrameworkAuthorizedTypeUpdate entries found, this script has to be run only one time per farm."
return
}
if( $farmMajorVersion -le 14 ) # 2010, 2007
{
foreach( $typeName in $typeNames )
{
# System, Version=2.0.0.0
$netFrameworkConfig = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$netFrameworkConfig.Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes"
$netFrameworkConfig.Name = "authorizedType[@Assembly='System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'][@Namespace='System.CodeDom'][@TypeName='{0}'][@Authorized='True']" -f $typeName
$netFrameworkConfig.Owner = "NetFrameworkAuthorizedTypeUpdate"
$netFrameworkConfig.Sequence = 0
$netFrameworkConfig.Type = [Microsoft.SharePoint.Administration.SPWebConfigModification+SPWebConfigModificationType]::EnsureChildNode
$netFrameworkConfig.Value = '<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System.CodeDom" TypeName="{0}" Authorized="True"/>' -f $typeName
$contentService.WebConfigModifications.Add($netFrameworkConfig);
}
}
else # 2013+
{
foreach( $typeName in $typeNames )
{
# System, Version=4.0.0.0
$netFrameworkConfig = New-Object Microsoft.SharePoint.Administration.SPWebConfigModification
$netFrameworkConfig.Path = "configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes/targetFx"
$netFrameworkConfig.Name = "authorizedType[@Assembly='System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'][@Namespace='System.CodeDom'][@TypeName='{0}'][@Authorized='True']" -f $typeName
$netFrameworkConfig.Owner = "NetFrameworkAuthorizedTypeUpdate"
$netFrameworkConfig.Sequence = 0
$netFrameworkConfig.Type = [Microsoft.SharePoint.Administration.SPWebConfigModification+SPWebConfigModificationType]::EnsureChildNode
$netFrameworkConfig.Value = '<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Namespace="System.CodeDom" TypeName="{0}" Authorized="True"/>' -f $typeName
$contentService.WebConfigModifications.Add($netFrameworkConfig);
}
}
Write-Verbose "Updating web.configs"
$contentService.Update()
$contentService.ApplyWebConfigModifications();
}
end
{
}
}
function Remove-CodeDomAuthorizedType
{
<#
.Synopsis
Removes any web configuration entries owned by "NetFrameworkAuthorizedTypeUpdate"
.DESCRIPTION
Removes any web configuration entries owned by "NetFrameworkAuthorizedTypeUpdate"
.EXAMPLE
Remove-CodeDomAuthorizedType
#>
[CmdletBinding()]
param()
begin
{
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
}
process
{
$webConfigModifications = @($contentService.WebConfigModifications | ? { $_.Owner -eq "NetFrameworkAuthorizedTypeUpdate" })
foreach ( $webConfigModification in $webConfigModifications )
{
Write-Verbose "Found instance owned by NetFrameworkAuthorizedTypeUpdate"
$contentService.WebConfigModifications.Remove( $webConfigModification ) | Out-Null
}
if( $webConfigModifications.Count -gt 0 )
{
$contentService.Update()
$contentService.ApplyWebConfigModifications()
}
}
end
{
}
}
# The following command will get the timerjob responsible for the web.config change deployment
# Get-SPTimerJob | ? { $_.Name -eq "job-webconfig-modification" }
# The following command will make the appropriate changes
Add-CodeDomAuthorizedType
# Remove the following command if you have to remove the web.config updates, you can use this function to retract the changes
# Remove-CodeDomAuthorizedType