In this article, I will show method used to get current logged In user using client object model.
private User GetCurrentLoggedInUser()
{
Web oWebSite = ClientContext.Current.Web;
ClientContext.Current.Load(oWebSite);
ClientContext.Current.ExecuteQuery();
User oUser = oWebSite.CurrentUser;
ClientContext.Current.Load(oUser);
ClientContext.Current.ExecuteQuery();
return oUser;
}
This method return User object. so to get loggedIn user create User class object and call this method.
Private User oUser = GetCurrentLoggedInUser ();
No comments:
Post a Comment