Csharp/C#教程:如何在SharePoint中使用选定的用户配置文件服务分享


如何在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):

上述就是C#学习教程:如何在SharePoint中使用选定的用户配置文件服务分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 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); 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/999841.html

(0)
上一篇 2021年12月27日
下一篇 2021年12月27日

精彩推荐