检索关联的共享服务提供商的名称? [英] Retrieving the associated shared service provider's name?

查看:86
本文介绍了检索关联的共享服务提供商的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何以编程方式检索与特定Sharepoint Web应用程序关联的共享服务提供商的名称?

How do you programmatically retrieve the name of a shared services provider that's associated with a specific Sharepoint web application?

我有一个自定义解决方案,需要:

I have a custom solution that needs to:

  1. 枚举部署到的所有Web应用程序
  2. 找出每个Web应用程序都与之关联的共享服务提供者
  3. 访问安装在SSP上的业务数据目录以检索一些数据
  4. 枚举那些Web应用程序中的所有网站集
  5. 根据数据执行网站集中的各种任务

我弄清楚了点1、3、4和5,但是2有点麻烦.我想避免在任何地方对SSP名称进行硬编码,并且不需要服务器场管理员手动编辑配置文件.我需要的所有信息都在Sharepoint配置数据库中,我只需要知道如何通过对象模型进行访问即可.

I got points 1, 3, 4 and 5 figured out, but 2 is somewhat troublesome. I want to avoid hardcoding the SSP name anywhere and not require the farm administrator to manually edit a configuration file. All information I need is in the Sharepoint configuration database, I just need to know how to access it through the object model.

推荐答案

不幸的是,我不知道可以做到的任何受支持的方式.相关类是Microsoft.Office.Server.Administration命名空间中Microsoft.Office.Server DLL中的SharedResourceProvider.它被标记为内部,因此很容易被反射:

Unfortunately there is no supported way I know of that this can be done. The relevant class is SharedResourceProvider in the Microsoft.Office.Server.Administration namespace, in the Microsoft.Office.Server DLL. It's marked internal so pre-reflection:

SharedResourceProvider sharedResourceProvider = ServerContext.GetContext(SPContext.Current.Site).SharedResourceProvider;
string sspName = sharedResourceProvider.Name;

反射后:

ServerContext sc = ServerContext.GetContext(SPContext.Current.Site);
PropertyInfo srpProp = sc.GetType().GetProperty(
    "SharedResourceProvider", BindingFlags.NonPublic | BindingFlags.Instance);
object srp = srpProp.GetValue(sc, null);
PropertyInfo srpNameProp = srp.GetType().GetProperty(
    "Name", BindingFlags.Public | BindingFlags.Instance);
string sspName = (string)srpNameProp.GetValue(srp, null);

另一种选择是不建议在配置数据库上编写SQL查询.

An alternative would be to write a SQL query over the configuration database which isn't recommended.

这篇关于检索关联的共享服务提供商的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆