I need to pass the current login user data from SharePoint 2010 to another web application. I am trying to use the javascript code to get the user and then pass it to the web application. I dont know where to start. My scenario is that I need to put a link on the SharePoint which would open a new form on a different web application and populate the user name value into it.

Any help would be appreciated.

Thanks in advance.

3 Answers 3


Here's how you can get the current user login name in Javascript: get-current-users-loginname-ecmascript-sharepoint-2010.

<script type="text/javascript">
var context = null;
var web = null;
var currentUser = null;
ExecuteOrDelayUntilScriptLoaded(GetUserLoginName, "sp.js");
function GetUserLoginName() {
context = new SP.ClientContext.get_current();
web = context.get_web();
this._currentUser = web.get_currentUser();
context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod),
Function.createDelegate(this, this.onFailureMethod));
function onSuccessMethod(sender, args) {
var today = new Date();
alert(' Name:' + this._currentUser.get_title() + '\n Login:' + this._currentUser.get_loginName());
function onFaiureMethod(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
  • Hi, Thanks for the solution. I had already tried this but this only gives me the name through the alert and provides a pop up. I need to copy the username and paste it into a form in another web application. I need to pass this username to different server.
    – Thisisme..
    Commented Mar 8, 2012 at 1:02

This code sometimes work well, sincerely I prefer use to SPServices.

with jquey:

var Username = $("#zz16_Menu").text();
alert(Username+" yname");

with only javascript:

var Username = document.getElementById("zz16_Menu").innerHTML ;
var end = Username.indexOf("<");
var nameOnly = Username.substring(8, end);
alert(nameOnly+" xname");

Best Regards


Use SPServices Jquery from CodePlex.

Do the necessary steps:

  1. Download the latest jquery.js from SPServices Jquery.

  2. Upload the minnified js file to the style library of your site.

  3. Add the script link <script type="text/javascript" src="Path of the JS file"> </script> to the master page.

  4. Add the following code

        fieldName: "Name",
        debug: false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.