SharePoint

Get Current LoggedIn User without Domain Name in SharePoint 2010

private string ReturnCurrentUserWithoutDomainName()
        {
            string currentUserWithDomainName = SPContext.Current.Web.CurrentUser.Name.ToString();
            if (currentUserWithDomainName.Contains("\\"))
            {
                string[] words = currentUserWithDomainName.Split('\\');
                return words[1];
            }
            else
            {
                return currentUserWithDomainName;
            }
        }

Standard

Leave a Reply

Your email address will not be published. Required fields are marked *