SharePoint Central Administration Feature 开发要点
来源:互联网 发布:企业秀是个什么软件 编辑:程序博客网 时间:2024/06/05 06:45
在SharePoint开发中,我们有时需要在Central Administration中部署Feature,这样的Feature(以下简称CA Feature)通常都是完成一些全局的管理操作,比如说公司开发出多个SharePoint可重用的组件,准备以产品的形式对外销售,这个时候就得通过部署一些CA Feature去对整个Farm中已经安装的SharePoint组件授权进行管理。
作为部署到Central Administration的Feature,与一般的Feature有些不同,现在总结如下:
1. Feature自动激活及隐藏
因为CA Feature用于管理,所以最好在部署的时候自动将其激活,同时将该Feature隐藏,不让它在Feature管理列表中显示。这样SharePoint Admin也省去了一些不必要的麻烦,同时也不让他有机会在别的站点上激活CA Feature。如下feature.xml示例:
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
AutoActivateInCentralAdmin="TRUE"
Hidden="TRUE"
Scope="WebApplication"
ReceiverAssembly="Demo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0ae3210f1d183ecb"
ReceiverClass="Demo.CentralAdminOnlyFeatureReceiver"
Title="Demo"
ActivateOnDefault="FALSE"
Id="3e624731-3917-49ea-916a-292c3689f188">
<ElementManifests>
<ElementManifest Location="Elements.xml" />
</ElementManifests>
</Feature>
注意:对于Farm Scope的Feature,AutoActivateInCentralAdmin这个属性是无效的,所以这里把它设置成WebApplication,不然CA Feature无法在Central Administration自动激活。
2. SPFeatureReceiver
前面我们把Feature Scope设置成WebApplication,如果不想让CA Feature在非Central Administration的Web Application上激活,那么我们需要在CA Feature激活的时候作一下检查,限制其激活,在上面的feature.xml中已将其添加进来,下面给出该Feature Receiver的定义。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace Demo
{
public class CentralAdminOnlyFeatureReceiver : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;
if (!webApp.IsAdministrationWebApplication)
{
Guid featureId = properties.Feature.DefinitionId;
webApp.Features.Remove(featureId, true);
webApp.Update();
throw new SPException(string.Format("You can activate the feature with ID {0} on the Central Administration Web Application only!", featureId));
}
}
}
}
这样当用户在非Central Administration的Web Application上激活CA Feature的时候,会立即将这个已激活的Feature移除,并且显示相应的错误信息。
- SharePoint Central Administration Feature 开发要点
- sharepoint中打不开Central administration
- 如何使用命令行重新设置SharePoint Central Administration?
- InfoPath与SharePoint之(八)发布InfoPath到Central Administration-部署到SharePoint
- Backup a farm by using SharePoint 2013 Central Administration and the Error Solution
- SharePoint 2013: The "New Web Application" button is disabled is the central administration
- InfoPath与SharePoint之(七)发布InfoPath到Central Administration-准备Full Trust的Template
- Change the Central Administration Web site port number (SharePoint Foundation 2010)
- Sharepoint站点feature的定制与开发
- sharepoint站点Feature的定制与开发
- WSS3SDK之:Microsoft.SharePoint 与 Microsoft.SharePoint.Administration下的开发
- SharePoint中的Feature(一)
- SharePoint 2013 Feature Details
- Beginning SharePoint Administration: Windows SharePoint Services and SharePoint Portal Server
- Sharepoint自定义Feature(5)-----Feature.xml结构
- Lose sharepoint site (forms-auth) administration rights
- 小议:Central Administration删除Web Application失败的解决方案
- SharePoint中的Feature(二)
- C++ 简单的文件操作_适合初学者
- FlashDevelp3.3.4+Molehill_alpha+Away3D4_alpha配置环境下的水波纹Demo编译
- onNewIntent与singleTask
- P240 程序设计: 猫大叫一声,所有的老鼠都开始逃跑,主人被惊醒。(VC版)
- strcat函数越界的问题
- SharePoint Central Administration Feature 开发要点
- Loader ,URLLoader ,URLStream的使用区别
- 网站札记1
- 2010年搜索引擎的发展状况
- Error creating managed object for vfszip
- SNMP4J教程
- 要学习VC
- hibernate.hbm2ddl.auto的属性值
- 重构小记_1