Getting the Current User in SharePoint 2010

SPervices is a jQuery library which abstracts SharePoint's Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful capabilities. It works entirely  on client side and requires no server side library.
 
Prior to Sharepoint 2013, you cant use CSOM to access user profile.SPservices seems to be rescue for sharepoint 2010 environment.
 
Here is the Jquery code which is used to fetch current user/logged in user in sharepoint 2010.
 
  • <script src="JavaScripts/jquery-1.8.3.min.js" type="text/javascript"></script>
    < script src="JavaScripts/jquery.SPServices-2013.01.min.js" type="text/javascript"></script>
    < script type="text/javascript">
    var UserAccount = $().SPServices.SPGetCurrentUser({fieldName: "ID", debug: false});

    alert("The Logged in User Account is "+UserAccount); 
    </script> 
     
    Happy SharePointing :-) 



Ebook Download
View all
Learn
View all