如何使用SharePoint选定的用户,配置文件服务 [英] How to use selected User-profile service in SharePoint

查看:189
本文介绍了如何使用SharePoint选定的用户,配置文件服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想提出一个计时器作业发送电子邮件birthdayWish从的SharePoint USERPROFILE服务牵强。
但是问题是我的多个用户配置文件服务器上的服务。

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.

像1)。 USERPROFILE服务1结果
2)。 USERPROFILE服务2结果
3)。 USERPROFILE服务3结果
4)。 。USERPROFILE服务4

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



所以这里的 SPServiceApplicationProxyGroup.Default 它让用户第一次高调。

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

其中我想使用第2用户配置文件服务。但默认情况下当试图访问其获得的 1的用户配置文件服务并遍历它。

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.

那么如何将其设置为使用第二个用户-profile服务。

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

推荐答案

我的猜测是,你有一个用户配置文件服务实例(UPS)与多个用户配置文件服务应用程序( UPA)就可以了(而不是多个UPS):

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

这篇关于如何使用SharePoint选定的用户,配置文件服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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