从 Silverlight 应用程序检索 Sharepoint 中的当前用户登录信息 [英] Retrieve current user login in Sharepoint from a Silverlight application
问题描述
是否可以从嵌入式 Silverlight 4 应用程序中检索在 sharepoint 上使用的当前用户登录信息?
Is it possible to retrieve the current user login used on sharepoint from an embedded Silverlight 4 application?
推荐答案
On SharePoint 2010
使用客户端对象模型(http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web.currentuser.aspx).
Use client object model (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web.currentuser.aspx).
类似于:
public void DoStuff()
{
ClientContext clientContext = ClientContext.Current;
clientContext.Load(clientContext.Web, s => s.CurrentUser);
clientContext.ExecuteQueryAsync((sender, args) => {
var currentUser = clientContext.Web.CurrentUser;
}, null);
}
在 SharePoint 2007 上
遗憾的是,SP2007 上不存在客户端对象模型.我之前做的是这样的:
Unfortunatly, the client object model does not exist on SP2007. What I did before is this:
- 使用 JQuery SPServices 库来获取我需要的东西 (http://spservices.codeplex.com/wikipage?title=$().SPServices.SPGetCurrentUser&referringTitle=Documentation)
- 使用 SL/JS 桥将其传递给我的 Silverlight 应用程序
我想有一个可以直接用于 Silverlight 的 WebService,但我不知道有一个.
I guess there is a WebService you can use directly to Silverlight, but I don't know one on the top of my head.
这篇关于从 Silverlight 应用程序检索 Sharepoint 中的当前用户登录信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!