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 upgraded our test environment from SharePoint 2010 to 2013. We were using classic authentication in 2010, migrated to claims (NTLM) in 2013. The databases have been upgraded and attached but the sites are still in "2010 mode".

We have a .NET server control with a string "UserName" property on the masterpage. Before the upgrade, we passed the string "DEFAULT" as the UserName to the control and the current user's username was somehow picked up and passed along. After the upgrade, the literal string "DEFAULT" is being passed through instead.

I'm assuming this has something to do with using claims authentication now... is there a different keyword I can use to get the current username?

Note: I am aware I can work around this by re-creating the control with javascript/ajax. I want to know if it's possible to continue using the server control.

share|improve this question

I made a few helper methods to get the AD login name from the windows claims. Hopefully these will help you fix your .NET server control.

The full story is located here:

But below are the highlights:

//Regex needs more testing
public const string CLAIMS_REGEX = @"(?<IdentityClaim>[ic])?:?0(?<ClaimType>[#\.5\!\+\-%?\\])(?<ClaimValueType>[\.\+])(?<AuthMode>[wstmrfc])(\|(?<OriginalIssuer>[^\|]*))?(\|(?<ClaimValue>.*))";

public static string GetAdUserIdForClaim(string login)
    string userName = login;

    foreach (Match m in Regex.Matches(login, CLAIMS_REGEX))
        userName = m.Groups["ClaimValue"].Captures[0].Value;
    return userName;
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.