组织浏览器 Web 部件不为 Windows 声明用户呈现
症状
在已启用 Windows 声明的网站上使用组织浏览器 Web 部件时,Web 部件不会呈现任何信息。 同一 Web 部件正确呈现具有不同声明身份验证类型的用户。
原因
组织信息是从用户配置文件服务应用程序的配置文件数据库中拉取的, (UPSA) 。 所需信息存储在 UserProfile_Full 表中。
Active Directory 用户 (手动添加或自动同步,) 使用 NETBIOS\LogonName (例如:CONTOSO\TestUser1) 格式存储在 UPSA 配置文件数据库中。
但是,浏览声明站点时,用户上下文使用 Claims NTName 格式。 (Ex.: i:0#.w|Contoso\TestUser1)
然后,组织浏览器 Web 部件为用户 “i'0#.w| 执行数据库查找”Contoso\TestUser1 在 数据库中不可用,因为用户信息将随“CONTOSO\TestUser1”NTName 一起存储。
任何其他声明身份验证类型都不会发生此问题,因为配置文件数据库包含正确的命名格式。
解决方案
组织浏览器 Web 部件控件由 CreateHierarchyChartControl javascript 函数呈现在页面上。 此函数不知道 UPSA 配置文件数据库存储具有不同命名格式的 Windows 声明用户这一事实。 若要解决此问题,必须在组织浏览器 Web 部件之后立即在网站源中输入以下代码片段。
<script type="text/javascript">
function CreateHierarchyChartControl(parentId, profileId, type, persistControlId) {
var i = profileId.indexOf("|");
var claimsmode = profileId.substr(i-1,1);
if((i >=0 ) & (claimsmode=="w"))
{
profileId = profileId.substr(i+1,profileId.length-i-1);
var initParam = profileId + ',' + type + ',' + persistControlId;
var host = document.getElementById(parentId);
host.setAttribute('width', '100%');
host.setAttribute('height', '100%');
Silverlight.createObject('/_layouts/ClientBin/hierarchychart.xap',
host,
'ProfileBrowserSilverlightControl',
{
top: '30',
width: '100%',
height: '100%',
version: '2.0',
isWindowless: 'true',
enableHtmlAccess: 'true'
},
{
onLoad: OnHierarchyChartLoaded
},
initParam,
null);
}
}
</script>
对于 SharePoint Server 2016
<script type="text/javascript">
function CreateHierarchyChartControl(parentId, profileId, type, persistControlId, flowDirection, silverLightControlId){
var i = profileId.indexOf("|");
var claimsmode = profileId.substr(i - 1, 1);
if ((i >= 0) & (claimsmode == "w")) {
profileId = profileId.substr(i + 1, profileId.length - i - 1);
var initParam = profileId + ',' + type + ',' + persistControlId + ',' + flowDirection + ',' + silverLightControlId;
var host = document.getElementById(parentId);
host.setAttribute('width', '100%');
host.setAttribute('height', '100%');
Silverlight.createObject('/_layouts/ClientBin/hierarchychart.xap',
host,
'ProfileBrowserSilverlightControl',
{
top: '30',
width: '100%',
height: '100%',
version: '2.0',
isWindowless: 'true',
enableHtmlAccess: 'true'
},
{
onLoad: OnHierarchyChartLoaded
},
initParam,
null);
}
}
//For html view
SP.UI.Portal.SimpleProfileBrowser.prototype.$35_0 = function(b, c, d) {
var i = b.indexOf("|");
b = b.substr(i + 1, b.length - i - 1);
var a = $get(c);
if (a) {
a.innerHTML = "<DIV></DIV><DIV></DIV><DIV></DIV>";
this.$m_0 = a.firstChild;
this.$1C_0 = this.$m_0.nextSibling;
this.$1a_0 = this.$1C_0.nextSibling
}
if (d) {
this.$m_0.innerHTML = String.format(SpsClient.ScriptResources.silverlight_Install_Message, "<a href='javascript:Silverlight.getSilverlight(\"2.0\");'>Silverlight</a>");
Sys.UI.DomElement.addCssClass(this.$m_0, "ms-profileBrowserHeaderText");
Sys.UI.DomElement.addCssClass(this.$m_0.firstChild.nextSibling, "ms-profileBrowserSilverlightLink")
}
this.$38_0(b)
}
</script>
方法 1:向页面添加内容编辑器 Web 部件
- 编辑包含组织浏览器 Web 部件的页面。
- 在组织浏览器 Web 部件后面添加内容编辑器 Web 部件。
- 编辑内容。
- 在功能区中,单击“设置文本格式”选项卡下的“HTML/编辑 HTML 源”。
- 复制粘贴上面的代码。
- 隐藏 Chrome 和 Web 部件的内容,使其不会出现在页面上。
方法 2:在 SharePoint Designer中编辑页面
请注意,此方法将从网站定义中分离页面,因此必须谨慎使用。
- 在 SharePoint Designer中打开页面进行编辑。
- 更改为代码视图。
- 在功能区中,单击“高级模式”
- <找到 / SharePoint:EmbeddedFormField> 标记。
- 将上述代码粘贴到 标记后面。
- 保存所做的更改。
- 在“网站定义页警告”窗口中单击“是”。
更多信息
请注意,无法从客户端覆盖组织浏览器 Web 部件的 Html 视图。 如果需要提供非 Silverlight 控件,则需要编写自定义 Web 部件才能使用 Windows 声明实现此目标。
仍然需要帮助? 请转到 SharePoint 社区。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈