激活实施 SPFeatureReceiver 的功能时访问被拒绝?
-
09-12-2019 - |
题
我们开发了一些实现 SPFeatureReceiver 接口的功能。当在开发环境中尝试这个时,它首先失败了,直到我发现 这个脚本来自MSDN:
function Set-RemoteAdministratorAccessDenied-False()
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") > $null
# get content web service
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
# turn off remote administration security
$contentService.RemoteAdministratorAccessDenied = $false
$contentService.Update()
}
Set-RemoteAdministratorAccessDenied-False
运行脚本并重置 IIS 后,一切都在开发中运行良好,我们可以在中激活该功能(作为 Farm Admin) Site Settings > Manage Site Features
范围设置为站点 http://mysolution/_layouts/ManageFeatures.aspx?Scope=Site. 。激活后,我们再次将属性 RemoteAdministratorAccessDenied 反转为 true,并执行了新的操作 IISRESET
.
在生产服务器上,我们在部署该功能后使用了相同的过程:
- 将 RemoteAdministratorAccessDenied 设置为 false
- IISRESET 并尝试激活该功能 - 但失败了。
我们返回的错误消息如下:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Access Denied.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[SecurityException: Access Denied.]
Microsoft.SharePoint.Administration.SPPersistedObject.BaseUpdate() +27451643
Microsoft.SharePoint.Administration.SPJobDefinition.Update() +152
Company.IssueTracker.Features.NewIssueTimerJob.NewIssueTimerJobEventReceiver.FeatureActivated(SPFeatureReceiverProperties properties) +837
Microsoft.SharePoint.SPFeature.DoActivationCallout(Boolean fActivate, Boolean fForce) +25671814
Microsoft.SharePoint.SPFeature.Activate(SPSite siteParent, SPWeb webParent, SPFeaturePropertyCollection props, Boolean fForce) +25676799
Microsoft.SharePoint.SPFeatureCollection.AddInternal(SPFeatureDefinition featdef, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly) +27776095
Microsoft.SharePoint.SPFeatureCollection.AddInternalWithName(Guid featureId, String featureName, Version version, SPFeaturePropertyCollection properties, Boolean force, Boolean fMarkOnly, SPFeatureDefinitionScope featdefScope) +150
Microsoft.SharePoint.SPFeatureCollection.Add(Guid featureId, Boolean force, SPFeatureDefinitionScope featdefScope) +83
Microsoft.SharePoint.WebControls.FeatureActivator.ActivateFeature(Guid featid, SPFeatureDefinitionScope featdefScope) +699
Microsoft.SharePoint.WebControls.FeatureActivatorItem.BtnActivateFeature_Click(Object objSender, EventArgs evtargs) +140
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11058199
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11057738
System.Web.UI.Page.ProcessRequest() +91
System.Web.UI.Page.ProcessRequest(HttpContext context) +240
ASP._layouts_managefeatures_aspx.ProcessRequest(HttpContext context) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4963; ASP.NET Version:2.0.50727.4971
我的环境:共享点服务器 2010
SharePoint 2007 中的相关问题:
解决方案
如果博客认为 C.链接到没有帮助我会尝试将功能设置为 WebApplication 范围,这可能是正确的事情,因为您要添加新的计时器作业。
我假设您在 FeatureDeactiving 中再次删除了该作业。在这种情况下,如果有人在两个网站中激活该功能,然后从其中一个网站中删除它,就会遇到问题。
其他提示
我相信您的问题已经在这里得到解决了? 尝试设置 WebApplication 属性时,FeatureActivated 事件接收器拒绝访问这个问题在这里得到了进一步的解释 http://blog.bugrapostaci.com/tag/remoteadministratoraccessdenied/
希望它有帮助,c: marius