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.

1 Answer 1


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: http://steve.thelineberrys.com/getting-active-directory-userid-from-windows-claim-in-sharepoint-2013/

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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