I have been searching around the web trying to find some help on this. We are working on a aspx page hosted on a Sharepoint2010 site. We have been able to successfully get the current logged in user's username in the format of "DomainName\UserName" - by using the below very basic code:

<asp:LoginName id="LoginName01" runat="server" FormatString={0}/>

Need help in getting the friendly display name of the user - "FirstName LastName" - of the current logged in user.

  • On SharePoint 2013, it's even worse since you get the extra 'i:0#.w' which added by the claims authentication. I'd recommend NOT to use string split, and instead to use SPClaimProviderManager.Local.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value – itsho Sep 2 '15 at 8:50

Try the following with Sharepoint designer

1- Add inside as

    <ParameterBinding Name="ListID" Location="None" DefaultValue="EF49CFE7-C6C4-42D6-8FCB-B10D6CDC0A35"/>
    <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
    <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
    <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
    <ParameterBinding Name="LogonUser" Location="ServerVariable(LOGON_USER)"/>

2- Add <xsl:param name="LogonUser"/> before template <xsl:template match="/">

3- You can get the value of current login as <xsl:value-of select="$LogonUser"/> inside your template

Another method using SPServices

  webURL: "",       // Added in 2013.01
  fieldName: "Name",
  fieldNames: {},       // Added in v0.7.2 to allow multiple columns
  debug: false

link: https://social.technet.microsoft.com/Forums/en-US/88c1d5e6-649f-4b97-91b3-07b2093fb931/get-current-login-user-in-sharepoint-desginer-codebehind?forum=sharepointcustomizationprevious




Try this SharePoint specific code

<%= SPContext.Current.Web.CurrentUser.Name %>

It should get you the users display name

  • I tried to put this into the ASPX page and it was still not pulling any - I literally copy-pasted the code you provided into the body of the HTML in between the <span> tag. Could be that am using it wrongly. Could you please help me with small example to how and where in the page i can use it to display the Display Name of the current logged in user. – Rahul Feb 1 '15 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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