代码改变世界

SharePoint 2013技巧分享系列 - Active Directory同步显示用户照片

2013-12-31 05:06  jv9  阅读(2469)  评论(1编辑  收藏  举报

为了保持通讯信息的一致性,需要设置SharePoint,Exchange, Lync等信息同步更新显示,例如,员工头像信息。 本文介绍如何在SharePoint 2013中同步显示Active Directory活动目录用户头像信息。

首先在用户属性Picture中导入AD活动目录属性,进入“Central Administration” -〉“Manage Service Applications”-〉“User Profile Service Application” -〉“Manage User Properties” -〉“Picture”

 

点击“Edit”,编辑Picture属性,

 

添加thumbnailPhoto属性到Picture中,

添加成功后,该属性会显示如下:

点击“OK”,确认保存。

 

退出用户属性编辑页面,进入User Profile主页面“Central Administration” -〉“Manage Service Applications”-〉“User Profile Service Application”,

点击“Start Profile Synchronization”,同步AD活动目录用户配置信息。该步骤会根据用户的数量决定运行时间长短,需要耐心等待。

同步完成后,需要运行以下PowerShell命令更新用户信息:

Update-SPProfilePhotoStore -CreateThumbnailsForImportedPhotos 1 -MySiteHostLocation http://<YourServerName>/People

运行完成后,刷新用户配置页面,即可看到同步后的用户照片。

 

需要注意的是,如果用户照片仍旧无法在SharePoint中显示,需要查看AD的thumbnailPhoto属性是否为空。这里推荐一个免费工具可以快捷查看AD属性,ADExplorer

运行ADExplorer后,按照以下条件查找

 

点击查找结果,在主显示页面会显示AD属性thumbnailPhoto,如果有数字显示则不为空,否则为空。

 

如果需要添加用户照片到AD活动目录,可以在AD服务器上运行以下PS代码,在运行前,需要确认照片已经存在,

$userName = “kevinfan”
$filePath = “c:\temp\kevinf.jpg”
[byte[]]$img = Get-Content $filePath –encoding byte
Get-ADUser –filter {samaccountname –eq $userName} |
Set-ADUser –replace @{thumbnailphoto=$img}

 

欢迎留言分享你的SharePoint 2013开发和设置技巧。