Tuesday, February 1, 2011

Way To Get The Current Logged-in Users Using The Client Object Model


In this article I will show the method used to obtain time users logged in using the client object model.


rivate 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 ();





SPONSORS:

No comments:

Post a Comment