从 asp.net 页面查看器 Web 部件显示当前经过身份验证的 Sharepoint 用户 [英] Displaying the current authenticated Sharepoint user from an asp.net Page Viewer Web Part

查看:9
本文介绍了从 asp.net 页面查看器 Web 部件显示当前经过身份验证的 Sharepoint 用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个独立的 asp.net 页面,该页面需要使用页面查看器 Web 部件嵌入到共享点站点中.asp.net 页面发布到同一服务器的不同端口上,为我提供了要嵌入的 URL.

I am creating a standalone asp.net page that needs to be embedded into a sharepoint site using the Page Viewer Web Part. The asp.net page is published to the same server on a different port, giving me the URL to embed.

要求是在用户使用 Sharepoint 身份验证进行身份验证后,他们导航到包含 asp.net Web 部件的页面以获取更多选项.

The requirement is that after a user is authenticated using Sharepoint authentication, they navigate to a page containing the asp.net web part for more options.

我需要在这个 asp.net 页面上做的是查询 Sharepoint 以获得当前经过身份验证的用户名,然后从 asp.net 代码将其显示在页面上.

What I need to do from this asp.net page is query Sharepoint for the currently authenticated username, then display this on the page from the asp.net code.

当我从 VS 调试应用程序时,这一切正常,但是当通过 Sharepoint 发布和显示时,我总是以用户身份获得 NULL.

This all works fine when I debug the application from VS, but when published and displayed though Sharepoint, I always get NULL as the user.

任何有关使其工作的最佳方式的建议将不胜感激.

Any suggestions on the best way to get this to work would be much appreciated.

推荐答案

如果要从 SharePoint 上下文中检索当前经过身份验证的用户,则需要保留在 SharePoint 上下文中.这意味着在 SharePoint 中托管您的自定义 Web 应用程序(请参阅 http://msdn.microsoft.com/en-us/library/cc297200.aspx).然后从您的自定义应用程序引用 Microsoft.SharePoint 并使用 SPContext 对象来检索用户名.例如:

If you want to retrieve the currently authenticated user from the SharePoint context, you need to remain within the SharePoint context. This means hosting your custom web application within SharePoint (see http://msdn.microsoft.com/en-us/library/cc297200.aspx). Then from your custom application reference Microsoft.SharePoint and use the SPContext object to retrieve the user name. For example:

SPContext.Current.Web.CurrentUser.LoginName

您仍然可以使用页面查看器 Web 部件来引用网站的 URL,现在位于 SharePoint 上下文中.

You can still use the Page Viewer Web Part to reference the URL of the site, now located within the SharePoint context.

这篇关于从 asp.net 页面查看器 Web 部件显示当前经过身份验证的 Sharepoint 用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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