Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude Windows Server 2016 from WAM support #629

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/shared/Core/Authentication/MicrosoftAuthentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static void InitializeBroker()
IsBrokerInitialized = true;

// Broker is only supported on Windows 10 and later
if (!PlatformUtils.IsWindows10OrGreater())
if (!PlatformUtils.IsWindowsBrokerSupported())
{
return;
}
Expand Down Expand Up @@ -288,7 +288,7 @@ private async Task<IPublicClientApplication> CreatePublicClientApplicationAsync(
}

// On Windows 10+ & .NET Framework try and use the WAM broker
if (enableBroker && PlatformUtils.IsWindows10OrGreater())
if (enableBroker && PlatformUtils.IsWindowsBrokerSupported())
{
#if NETFRAMEWORK
appBuilder.WithExperimentalFeatures();
Expand Down Expand Up @@ -459,8 +459,8 @@ public HttpClient GetHttpClient()
public static bool CanUseBroker(ICommandContext context)
{
#if NETFRAMEWORK
// We only support the broker on Windows 10 and require an interactive session
if (!context.SessionManager.IsDesktopSession || !PlatformUtils.IsWindows10OrGreater())
// We only support the broker on Windows 10+ and in an interactive session
if (!context.SessionManager.IsDesktopSession || !PlatformUtils.IsWindowsBrokerSupported())
{
return false;
}
Expand Down
47 changes: 45 additions & 2 deletions src/shared/Core/PlatformUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static PlatformInformation GetPlatformInformation()
return new PlatformInformation(osType, osVersion, cpuArch, clrVersion);
}

public static bool IsWindows10OrGreater()
public static bool IsWindowsBrokerSupported()
{
if (!IsWindows())
{
Expand All @@ -38,7 +38,27 @@ public static bool IsWindows10OrGreater()
return false;
}

return (int) osvi.dwMajorVersion >= 10;
// Windows major version 10 is required for WAM
if (osvi.dwMajorVersion < 10)
{
return false;
}

// Specific minimum build number is different between Windows Server and Client SKUs
const int minClientBuildNumber = 15063;
const int minServerBuildNumber = 17763; // Server 2019

switch (osvi.wProductType)
{
case VER_NT_WORKSTATION:
return osvi.dwBuildNumber >= minClientBuildNumber;

case VER_NT_SERVER:
case VER_NT_DOMAIN_CONTROLLER:
return osvi.dwBuildNumber >= minServerBuildNumber;
}

return false;
}

/// <summary>
Expand Down Expand Up @@ -283,8 +303,31 @@ private unsafe struct RTL_OSVERSIONINFOEX
internal uint dwBuildNumber;
internal uint dwPlatformId;
internal fixed char szCSDVersion[128];
internal ushort wServicePackMajor;
internal ushort wServicePackMinor;
internal short wSuiteMask;
internal byte wProductType;
internal byte wReserved;
}

/// <summary>
/// The operating system is Windows client.
/// </summary>
private const byte VER_NT_WORKSTATION = 0x0000001;

/// <summary>
/// The system is a domain controller and the operating system is Windows Server.
/// </summary>
private const byte VER_NT_DOMAIN_CONTROLLER = 0x0000002;

/// <summary>
/// The operating system is Windows Server.
/// </summary>
/// <remarks>
/// A server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER, not VER_NT_SERVER.
/// </remarks>
private const byte VER_NT_SERVER = 0x0000003;

#endregion
}

Expand Down