如何在 SharePoint 中使用选定的用户配置文件服务

发布于 2024-12-28 17:50:06 字数 724 浏览 1 评论 0原文

基本上,我正在制作一个计时器作业来发送从 SharePoint 用户配置文件服务 获取的birthdayWish 电子邮件。 但问题是我在服务器上有多个用户配置文件服务。

像1)。用户配置文件服务1
2)。用户配置文件服务2
3)。用户配置文件服务3
4). userprofile service4

那么如何使用第二个用户配置文件服务。

这是我所做的一些代码:

    SPServiceContext oServiceContext = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);

     UserProfileManager oProfileManager = new UserProfileManager(oServiceContext);

因此,在 SPServiceApplicationProxyGroup.Default 中,它获取第一个用户配置文件。

其中我想使用第二个用户配置文件服务。但默认情况下,当尝试访问其获取第一个用户配置文件服务并迭代它时。

那么如何将其设置为使用第二个用户配置文件服务。

Basically I am making a timer job to send a birthdayWish email fetched from SharePoint userprofile service.
But problem is I have multiple userprofile services on server.

like 1). userprofile service1
2). userprofile service2
3). userprofile service3
4). userprofile service4

So how to use 2nd user-profile service.

Here's some code, that I did:

    SPServiceContext oServiceContext = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);

     UserProfileManager oProfileManager = new UserProfileManager(oServiceContext);

So here in SPServiceApplicationProxyGroup.Default its getting 1st user-profile.

Among them I want to use 2nd user-profile service. but by default when trying to access its getting 1st user-profile service and iterate through it.

So how to set it to use 2nd user-profile service.

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

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

发布评论

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

评论(1

圈圈圆圆圈圈 2025-01-04 17:50:06

我的猜测是,您有一个 User Profile Service 实例 (UPS),其上有多个 User Profile Service 应用程序 (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);

My guess is that you have one User Profile Service Instance (UPS) with multiple User Profile Service Applications (UPA) on it (and not multiple 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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文