【问题标题】:Activating custom feature using FBA in sharepoint在 sharepoint 中使用 FBA 激活自定义功能
【发布时间】:2010-11-02 08:31:02
【问题描述】:
我已经使用基于表单的身份验证为 sharepoint 中的站点创建了一个带有自定义功能接收器的功能。
但是,每当我尝试激活该功能时(即使基于表单的帐户拥有最高权限),我都会收到 403 - “需要您登录”。
我可以很好地激活和停用其他功能,但不是我的自定义功能。使用功能接收器创建功能是否有特殊技巧允许我这样做?
谢谢
【问题讨论】:
标签:
c#
sharepoint
sharepoint-2007
forms-authentication
【解决方案1】:
显然,完全的管理员模拟和 RunWithElevatedPrivileges 成功了。
这是任何感兴趣的人的代码(在 FeatureActivated/-Deactivated 方法中):
SPSecurity.RunWithElevatedPrivileges(delegate() {
SPWeb _web = properties.Feature.Parent as SPWeb;
SPUserToken sysAdmin = _web.Site.SystemAccount.UserToken;
using (SPSite elevatedSite = new SPSite(_web.Site.ID, sysAdmin)) {
using (SPWeb web = elevatedSite.OpenWeb(_web.ID)) {
//Code goes here...
}
}
});