如何在SharePoint中使用选定的用户配置文件服务
基本上我正在做一个计时器工作来发送从SharePoint userprofile服务获取的birthdayWish电子邮件。 但问题是我在服务器上有多个 userprofile服务。
像1)。 userprofile service1
2)。 userprofile service2
3)。 userprofile service3
4)。 userprofile service4
那么如何使用第二个用户配置文件服务。
这是一些代码,我做了:
SPServiceContext oServiceContext = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default); UserProfileManager oProfileManager = new UserProfileManager(oServiceContext);
因此,在SPServiceApplicationProxyGroup.Default中获取第一个用户配置文件。
其中我想使用第二个用户配置文件服务 。 但在默认情况下尝试访问其获取第一个用户配置文件服务并迭代它。
那么如何设置它以使用第二个用户配置文件服务。
我的猜测是你有一个用户配置文件服务实例(UPS)上有多个用户配置文件服务应用程序(UPA)(而不是多个UPS):
var userAppName = "userprofile service2"; SPFarm farm = SPFarm.Local; SPServiceApplication application; foreach (SPService s in farm.Services) { if(s.TypeName.Contains("User Profile Service")) { //We found UPS foreach(SPServiceApplication app in s.Applications) { if(app.Name == userAppName) application = app; //Here is UPA } } } //Or if you like oneliner (not 100% safe) var x = farm.Services.First(s => s.TypeName.Contains("User Profile Service")) .Applications.FirstOrDefault(app => app.Name == userAppName);
- 从ASP.NET网站发送SMS文本消息
- Nunit测试MVC网站
- 当客户端连接到’localhost’上的服务时,为什么System.Net.ServicePoint.ConnectionLimit使用’7FFFFFFF’(Int32.MaxValue / 2147483647)?
- 在C#中使用xmlnamespacemanager添加命名空间
- WCF Restful返回HttpResponseMessage想要在设置内容时进行协商
- 使用Linq查询作为数据源的ASP.NET GridView分页
- 为什么asp.net会话比其超时更早到期?
- 在DCOM配置中找不到Microsoft Word文档
- 我应该如何在ASP.NET中记录exception?