从一个asp.net页面查看器Web部件显示当前已验证的SharePoint用户 [英] Displaying the current authenticated Sharepoint user from an asp.net Page Viewer Web Part
问题描述
我创建需要被嵌入到使用网页查看器Web部件在SharePoint站点的独立页面asp.net。在asp.net页面发布到同一个服务器的不同端口上,给我的网址嵌入
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页面做的是为当前认证的用户名查询共享点,然后从asp.net code中的页面上显示这一点。
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的显示时,我总是空的用户。
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.
这是最好的办法任何建议得到这个工作将是非常美联社preciated。
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部件引用该网站,现在位于SharePoint环境中的URL。
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屋!