阻止用户激活 Sharepoint 中的功能

发布于 2024-09-03 04:12:11 字数 56 浏览 7 评论 0原文

如果我在场级别部署解决方案,是否可以通过某种方式阻止各个网站集的所有者激活该解决方案中存在的功能?

If I deploy a solution at farm level, is there a way by which i can prevent the owners of the various site collections from activating the features present in that solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流云如水 2024-09-10 04:12:11

阻止网站集用户激活特定功能的一个简单方法是将其标记为隐藏。这些功能实际上只允许场管理员通过 STSADM 命令激活。

要隐藏功能,请将功能元素的隐藏属性更新为“TRUE”,如下所示:

<Feature 
      Id="AD2146D-62DA-4911-DBC1-AE177DE40084"
      Title="Restricted Web Parts" 
      Hidden="TRUE"
      .../>

或者,如果您使用的是 SharePoint 2010,则可以使用功能包通过将一组功能定位到一组特定用户来解决此问题。

A simple way to prevent site collection users from activating a certain feature is to mark it as hidden. These features are then effectively only allowed to be activated by farm administrators through STSADM commands.

To hide a feature update the Hidden attribute of the Feature element to ‘TRUE’ as shown below:

<Feature 
      Id="AD2146D-62DA-4911-DBC1-AE177DE40084"
      Title="Restricted Web Parts" 
      Hidden="TRUE"
      .../>

Alternatively if you are using SharePoint 2010 you can use Feature Packs to solve this problem by targeting a set of features to a particular set of users.

_畞蕅 2024-09-10 04:12:11

如果在功能激活期间发生错误,则不会激活该功能,并且会撤回可能已作为 Elements Manifest 的一部分部署的任何效果。

因此,通过巧妙地使用此功能,您可以使用功能接收器的 FeatureActivated 部分来检查谁正在激活它,并抛出 UnauthorizedAccessException 和一条适当的错误消息,详细说明为什么无法激活该功能。这将显示为标准 SharePoint 错误页面,并包含您指定的消息。如果您已经在该功能上有一个功能接收器,则需要将其附加到 FeatureActivated 部分的开头,以便不会发生任何编程操作(与元素清单不同,这些操作不会在激活不成功时撤回)。

如果您以前没有使用过功能接收器,则只需两部分即可建立它。

  1. 在要素的要素 XML 中,将以下两个属性添加到要素节点。

    ReceiverAssembly=(四部分组件字符串)
    ReceiverClass=(接收者类的完整命名空间.类名)
    
  2. 编写一个接收器类。它继承自 SPFeatureReceiver,并且在 FeatureActivatedFeatureDeactivatingFeatureInstalledFeatureUninstalling 中具有 4 个必需的重写。对于最后 3 个过程,您无需执行任何操作。您将在 FeatureActivated 方法中编写安全检查。

If an error occurs during feature activation, it will not activate the feature and will retract any effects which might have been deployed as part of the Elements Manifest.

So, through crafty usage of this, you can use the FeatureActivated portion of a feature receiver to check who is activating it, and throw an UnauthorizedAccessException with an appropriate error message detailing why the feature cannot be activated. This will show up as the standard SharePoint error page with the message you specify. If you already have a feature receiver on the feature, you need to append this at the start of the FeatureActivated portion, so that any programmatic actions don't occur (unlike elements manifest, these are not retracted on unsuccessful activation).

If you haven't used a Feature Receiver before, you just need two parts to establish it.

  1. In the feature XML of your feature, add the following two attributes to the Feature node.

    ReceiverAssembly=(four-part-assembly-string)
    ReceiverClass=(full namespace.class name of receiver class)
    
  2. Write a receiver class. This inherits from SPFeatureReceiver, and has 4 required overrides in FeatureActivated, FeatureDeactivating, FeatureInstalled, and FeatureUninstalling. You don't have to do anything for the last 3. You'll write your security check in the FeatureActivated method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文