簡體   English   中英

如何在SharePoint 2013中檢索當前用戶的聲明

[英]How to retrieve claims for current user in SharePoint 2013

如何在SharePoint 2013中檢索當前用戶的聲明?

在早期版本(SP 2010 / .NET 3.5)中,我可以使用下面的代碼,但是.NET 4.5中與Claims相關的API已更改。 因此,.NET 4.5實現該目標的方法是什么?

IClaimsPrincipal cp = Page.User as IClaimsPrincipal;
IClaimsIdentity ci = (IClaimsIdentity)cp.Identity;
foreach (Claim c in ci.Claims)
{
}

嘗試這個:

 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM