索赔环境中用户主体名称的SharePoint UserProfile

索赔环境中用户主体名称的SharePoint UserProfile,sharepoint,user-profile,claims,upn,Sharepoint,User Profile,Claims,Upn,我有一个使用用户主体名称(UPN)格式保存在数据库中的帐户:jdoe@domain.gobalx.com 我在SharePoint环境中工作,该环境使用UPN格式进行身份验证 我的问题是我需要为持久化的UPN帐户获取一个UserProfile对象。我尝试了以下方法,但无效: string upnAccount = "jdoe@domain.globalx.com"; SPServiceContext ctx = SPServiceContext.GetContext(SPContext.Curr

我有一个使用用户主体名称(UPN)格式保存在数据库中的帐户:jdoe@domain.gobalx.com

我在SharePoint环境中工作,该环境使用UPN格式进行身份验证

我的问题是我需要为持久化的UPN帐户获取一个UserProfile对象。我尝试了以下方法,但无效:

string upnAccount = "jdoe@domain.globalx.com";
SPServiceContext ctx = SPServiceContext.GetContext(SPContext.Current.Site);
UserProfileManager upm = new UserProfileManager(ctx);
UserProfile user = upm.GetUserProfile(upnAccount);
我一直收到:Microsoft.Office.Server.UserProfiles.UserNotFoundException:检索用户配置文件时遇到错误


这是否意味着我必须将UPN帐户转换为声明,如果是,是否有人提供了如何转换的示例?

在某些情况下,在具有联合身份验证的SharePoint网站下,在您未设置同步之前,不会自动创建用户配置文件。对于此问题,您可以检查是否已经存在的用户配置文件jdoe@domain.globalx.com通过中央管理


此外,您的代码必须在模拟下运行,请检查日志中是否存在异常,并尝试使用SPSecurity.RunWithElevatedPrivileges。

在某些情况下,在具有联合身份验证的SharePoint网站下,在未设置同步之前,不会自动创建用户配置文件。对于此问题,您可以检查是否已经存在的用户配置文件jdoe@domain.globalx.com通过中央管理

            UserProfileManager UPM = null;

            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    ServerContext serverContext = ServerContext.GetContext(site);
                    UPM = new UserProfileManager(serverContext);
                     foreach (UserProfile profile in UPM)
                    {

                        an = profile["AccountName"].Value;
                        title = profile["Title"].Value;
                    }
                }
            }
此外,您的代码必须在模拟下运行,请检查日志中是否存在异常,并尝试使用SPSecurity.RunWithElevatedPrivileges

            UserProfileManager UPM = null;

            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    ServerContext serverContext = ServerContext.GetContext(site);
                    UPM = new UserProfileManager(serverContext);
                     foreach (UserProfile profile in UPM)
                    {

                        an = profile["AccountName"].Value;
                        title = profile["Title"].Value;
                    }
                }
            }
您可以尝试此方法获取所有用户配置文件。在foreach循环中,您可以检查字段并获得相应的用户详细信息

您可以尝试此方法获取所有用户配置文件。在foreach循环中,您可以检查字段并获得相应的用户详细信息