用户个人资料照片-没有来自URL的照片,但可以在sharepoint中看到照片. [英] User profile photo - no photo from URL but can see photo in sharepoint.

查看:76
本文介绍了用户个人资料照片-没有来自URL的照片,但可以在sharepoint中看到照片.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图弄清楚这一点.我的任务是编写一些代码以从Sharepoint获取用户的照片,以便我们可以在其他地方使用它.

我的代码使用photoURL的员工个人资料属性来获取照片.问题是,当我这样做时,许多照片会以无照片(小人物剪影)的形式返回,但是如果我在SharePoint,办公室和/或Skype中查看那些人的话 他们有照片.

我正在使用C#和CSOM来做到这一点.如何获取照片?是否还有其他地方可以使他们比SharePoint租户更具权威性?

解决方案

您是否在线使用SharePoint?

如果是,请参考以下示例代码:

使用(var clientContext = new ClientContext("https://xxx.sharepoint.com/sites/lee/"))
            {
                字符串密码="pw";
                SecureString sec_pass =新的SecureString();
                Array.ForEach(password.ToArray(),sec_pass.AppendChar);
                sec_pass.MakeReadOnly();
                clientContext.Credentials =新的SharePointOnlineCredentials("user@xxx.onmicrosoft.com",sec_pass);

                //获取人员管理器实例并加载当前属性
                PeopleManager peopleManager =新的PeopleManager(clientContext);
                PersonProperties personProperties = peopleManager.GetMyProperties();

                clientContext.Load(personProperties,p => p.AccountName);
                clientContext.ExecuteQuery();

                //
                var pictureURL = peopleManager.GetUserProfilePropertyFor(personProperties.AccountName,"PictureURL");
                clientContext.ExecuteQuery();
                Console.WriteLine(pictureURL.Value);
                Console.ReadKey();

            } 

此处提供了一些链接供您参考.

对于SharePoint Online,我建议您在在线论坛上发布,这样不会造成误会.

最好的问候,


Trying to figure this one out. I am tasked with writing some code to get a user's photo from Sharepoint so we can use it elsewhere. 

My code works to get the photo using the employee's profile property for the photoURL. Problem is that when I do this, many photos come back as the no photo (the little person silhouette) but if I look at those people in SharePoint, office, and/or Skype they have a photo.

I'm using C# and CSOM to do this. How do I get the photos? Is there another place to go get them that is more definitive over SharePoint tenant?

解决方案

Hi,

Are you using SharePoint online?

If so, here is sample code for your reference:

using (var clientContext = new ClientContext("https://xxx.sharepoint.com/sites/lee/"))
            {
                string password = "pw";
                SecureString sec_pass = new SecureString();
                Array.ForEach(password.ToArray(), sec_pass.AppendChar);
                sec_pass.MakeReadOnly();
                clientContext.Credentials = new SharePointOnlineCredentials("user@xxx.onmicrosoft.com", sec_pass);

                // Get the people manager instance and load current properties
                PeopleManager peopleManager = new PeopleManager(clientContext);
                PersonProperties personProperties = peopleManager.GetMyProperties();                

                clientContext.Load(personProperties, p => p.AccountName);
                clientContext.ExecuteQuery();

                //
                var pictureURL= peopleManager.GetUserProfilePropertyFor(personProperties.AccountName, "PictureURL");
                clientContext.ExecuteQuery();
                Console.WriteLine(pictureURL.Value);
                Console.ReadKey();

            }

Here are some links for your reference.

https://github.com/SharePoint/PnP/tree/master/Samples/UserProfile.Manipulation.CSOM

https://github.com/SharePoint/PnP/tree/master/Samples/UserProfile.Manipulation.CSOM.Console

For SharePoint Online case, I would suggest you post in online forum, so it would not cause misunderstanding.

https://social.technet.microsoft.com/Forums/msonline/en-US/home?forum=onlineservicessharepoint

Best Regards,

Lee


这篇关于用户个人资料照片-没有来自URL的照片,但可以在sharepoint中看到照片.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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