Access Umbraco back office user from the front end

If you need to access the current user logged into the Umbraco Backoffice from the Front End (to show a link to administrator area for example) you may have tried:

umbraco.BusinessLogic.User.GetCurrent()
UmbracoContext.UmbracoUser
UmbracoContext.Security.CurrentUser
umbraco.helper.GetCurrentUmbracoUser()

None of which seem to work, then you should user the following code:

@using Umbraco.Core.Security;
var userTicket = new System.Web.HttpContextWrapper(System.Web.HttpContext.Current).GetUmbracoAuthTicket();
if (userTicket != null) {     
 var currentUser = ApplicationContext.Services.UserService.GetByUsername(userTicket.Name);
}

As Andrew Wilson mentions in the comments, remember to include Umbraco.Core.Security – though if you forget hopefully Visual Studio will tell you to add it.