public static string? GetUserPrincipalName()

in src/Authentication/WindowsIntegratedAuth.cs [22:46]


    public static string? GetUserPrincipalName()
    {
        try
        {
            const int NameUserPrincipal = 8;
            uint userNameSize = 0;
            GetUserNameEx(NameUserPrincipal, null, ref userNameSize);
            if (userNameSize == 0)
            {
                return null;
            }

            StringBuilder sb = new StringBuilder((int)userNameSize);
            if (!GetUserNameEx(NameUserPrincipal, sb, ref userNameSize))
            {
                return null;
            }

            return sb.ToString();
        }
        catch
        {
            return null;
        }
    }