Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 没有管理用户配置文件权限的Sharepoint UserProfileManager_C#_Sharepoint - Fatal编程技术网

C# 没有管理用户配置文件权限的Sharepoint UserProfileManager

C# 没有管理用户配置文件权限的Sharepoint UserProfileManager,c#,sharepoint,C#,Sharepoint,我有一个让我有点发疯的问题:将UserProfileManager用作非授权用户 问题:用户没有“管理用户配置文件”权限,但我仍然希望使用UserProfileManager。使用SPSecurity.RunWithElevatedPrivileges的想法似乎不起作用,因为UserProfileManager似乎对SSP进行了授权 SPSecurity.RunWithElevatedPrivileges(delegate() {

我有一个让我有点发疯的问题:将UserProfileManager用作非授权用户

问题:用户没有“管理用户配置文件”权限,但我仍然希望使用UserProfileManager。使用SPSecurity.RunWithElevatedPrivileges的想法似乎不起作用,因为UserProfileManager似乎对SSP进行了授权

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(inputWeb.Site.ID))
                {
                    ServerContext ctx = ServerContext.GetContext(site);
                    UserProfileManager upm = new UserProfileManager(ctx,true);
                    UserProfile u = upm.GetUserProfile(userLogin);
                    DepartmentName = u["Department"].Value as string;
                }
            });
此操作在“new UserProfileManager”行仍然失败,出现“必须具有管理用户配置文件的管理员权限才能使用管理员模式”异常

就我的用户而言,RunWithElevatedPrivileges恢复为AppPool标识。WindowsIdentity.GetCurrent().Name返回“NT AUTHORITY\network service”,并且我已授予该帐户管理用户配置文件的权限-运气不好

site.RootWeb.CurrentUser.LoginName为在RunWithElevatedPrivileges中创建的网站返回SHAREPOINT\system,该网站不是有效的Windows帐户ofc


有没有办法做到这一点?我不想授予所有用户“管理用户配置文件”的权限,但我只想从用户配置文件(部门、国家/地区、直接报告)中获取一些数据。有什么想法吗?

需要设置的权限实际上可以在共享服务提供商中找到

  • 导航到管理中心
  • 导航到共享服务提供商
  • 在“用户配置文件和我的网站”下,导航到“个性化服务”权限
  • 如果该帐户尚不存在,请添加运行站点应用程序域的帐户
  • 授予该用户“管理用户配置文件”权限

  • 我注意到您正在网络服务帐户下运行应用程序池。我在我的网站上实现了相同的功能;但是,应用程序池托管在Windows帐户下。但是,我不确定这会有什么不同。

    我实际上有两种方法可以做到这一点:

  • 将使用UserProfileManager的代码放在web服务层后面。web服务应该使用可以访问用户配置文件服务的应用程序池标识
  • 使用以下文章中描述的模拟技术:

  • 谢谢你的回答。一个警告:如果你将应用程序池作为“网络服务”而不是域帐户运行,你就完蛋了


    不过,还是建议您使用域帐户(在测试服务器上,我使用了网络服务,但在将其更改为域帐户后,它仍然有效)。

    答案如下。这是一个愚蠢的微软错误,还有一个修补程序。我现在下载来测试它


    这似乎不适用于网络服务。在周末,我将尝试它是否适用于域帐户。无论如何,AFAIK都建议使用域帐户,但我的开发机器是一个独立的服务器。很有趣。这个周末之后我会在这个帖子上查看。如果它仍然不起作用,请给我留下另一条评论,我会看看能找到什么。您的代码看起来很好,我知道这是可行的,因为我以前做过。是的,这就是我经过一天的尝试,尝试将模拟还原到网络服务,然后创建用户配置文件属性后得出的结论。这一切都以本机方法结束,而该方法不授予您权限。谢谢。我很快也会去看看。