Skip to content

Instantly share code, notes, and snippets.

@ngbrown
Created April 24, 2018 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngbrown/fdea5b83fdb546dad140072f374f3b75 to your computer and use it in GitHub Desktop.
Save ngbrown/fdea5b83fdb546dad140072f374f3b75 to your computer and use it in GitHub Desktop.
using System;
using System.Security.Principal;
internal static class IdentityExtensions
{
internal static string GetNormalizedLogin(this IIdentity identity)
{
if (identity == null)
{
throw new ArgumentNullException(nameof(identity));
}
string s = identity.Name;
if (s == null)
{
return String.Empty;
}
int stop = s.IndexOf("\\", StringComparison.OrdinalIgnoreCase);
return (stop > -1) ? s.Substring(stop + 1, s.Length - stop - 1) : s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment