如何在SharePoint 2013中检索当前用户的声明?
在早期版本(SP 2010 / .NET 3.5)中,我可以使用下面的代码,但在.NET 4.5中,与声明相关的API已经更改。那么,.NET 4.5实现同样的方法是什么?
IClaimsPrincipal cp = Page.User as IClaimsPrincipal;
IClaimsIdentity ci = (IClaimsIdentity)cp.Identity;
foreach (Claim c in ci.Claims)
{
}
答案 0 :(得分:-3)
试试这个:
ClientContext clientContext =
TokenHelper.GetClientContextWithAccessToken(
sharepointUrl.ToString(), accessToken);
//Load the properties for the Web object.
Web web = clientContext.Web;
clientContext.Load(web);
clientContext.ExecuteQuery();
//Get the site name.
siteName = web.Title;
//Get the current user.
clientContext.Load(web.CurrentUser);
clientContext.ExecuteQuery();
currentUser = clientContext.Web.CurrentUser.LoginName