Skip to content

Commit

Permalink
Merge pull request #629 from mjcheetham/wam-server2016
Browse files Browse the repository at this point in the history
Exclude Windows Server 2016 from WAM support
  • Loading branch information
mjcheetham authored Mar 2, 2022
2 parents f90386c + 297d9a4 commit 2a077a8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
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

0 comments on commit 2a077a8

Please sign in to comment.