SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 4 down vote accepted

Here's how you can get the current user login name in Javascript:

<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());
share|improve this answer
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.. Mar 8 '12 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

share|improve this answer

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

    $().SPServices.SPGetCurrentUser({ fieldName: "Name", debug: false });

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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