Skip to content

Commit 297d9a4

Browse files
committed
windows-broker: exclude WinServer2016 from WAM support
Windows Server 2016 does not support WAM, so we should not try to enable the broker unless we're on Server 2019 and later. Also update the Windows (client; non-server) version checks to be tighter. Previously any major version of 10 or greater was considered "supported", but this is wrong. Windows 10 build 15063 was the first to support WAM.
1 parent 6b347f4 commit 297d9a4

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

src/shared/Core/Authentication/MicrosoftAuthentication.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void InitializeBroker()
5555
IsBrokerInitialized = true;
5656

5757
// Broker is only supported on Windows 10 and later
58-
if (!PlatformUtils.IsWindows10OrGreater())
58+
if (!PlatformUtils.IsWindowsBrokerSupported())
5959
{
6060
return;
6161
}
@@ -288,7 +288,7 @@ private async Task<IPublicClientApplication> CreatePublicClientApplicationAsync(
288288
}
289289

290290
// On Windows 10+ & .NET Framework try and use the WAM broker
291-
if (enableBroker && PlatformUtils.IsWindows10OrGreater())
291+
if (enableBroker && PlatformUtils.IsWindowsBrokerSupported())
292292
{
293293
#if NETFRAMEWORK
294294
appBuilder.WithExperimentalFeatures();
@@ -459,8 +459,8 @@ public HttpClient GetHttpClient()
459459
public static bool CanUseBroker(ICommandContext context)
460460
{
461461
#if NETFRAMEWORK
462-
// We only support the broker on Windows 10 and require an interactive session
463-
if (!context.SessionManager.IsDesktopSession || !PlatformUtils.IsWindows10OrGreater())
462+
// We only support the broker on Windows 10+ and in an interactive session
463+
if (!context.SessionManager.IsDesktopSession || !PlatformUtils.IsWindowsBrokerSupported())
464464
{
465465
return false;
466466
}

src/shared/Core/PlatformUtils.cs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static PlatformInformation GetPlatformInformation()
2121
return new PlatformInformation(osType, osVersion, cpuArch, clrVersion);
2222
}
2323

24-
public static bool IsWindows10OrGreater()
24+
public static bool IsWindowsBrokerSupported()
2525
{
2626
if (!IsWindows())
2727
{
@@ -38,7 +38,27 @@ public static bool IsWindows10OrGreater()
3838
return false;
3939
}
4040

41-
return (int) osvi.dwMajorVersion >= 10;
41+
// Windows major version 10 is required for WAM
42+
if (osvi.dwMajorVersion < 10)
43+
{
44+
return false;
45+
}
46+
47+
// Specific minimum build number is different between Windows Server and Client SKUs
48+
const int minClientBuildNumber = 15063;
49+
const int minServerBuildNumber = 17763; // Server 2019
50+
51+
switch (osvi.wProductType)
52+
{
53+
case VER_NT_WORKSTATION:
54+
return osvi.dwBuildNumber >= minClientBuildNumber;
55+
56+
case VER_NT_SERVER:
57+
case VER_NT_DOMAIN_CONTROLLER:
58+
return osvi.dwBuildNumber >= minServerBuildNumber;
59+
}
60+
61+
return false;
4262
}
4363

4464
/// <summary>
@@ -283,8 +303,31 @@ private unsafe struct RTL_OSVERSIONINFOEX
283303
internal uint dwBuildNumber;
284304
internal uint dwPlatformId;
285305
internal fixed char szCSDVersion[128];
306+
internal ushort wServicePackMajor;
307+
internal ushort wServicePackMinor;
308+
internal short wSuiteMask;
309+
internal byte wProductType;
310+
internal byte wReserved;
286311
}
287312

313+
/// <summary>
314+
/// The operating system is Windows client.
315+
/// </summary>
316+
private const byte VER_NT_WORKSTATION = 0x0000001;
317+
318+
/// <summary>
319+
/// The system is a domain controller and the operating system is Windows Server.
320+
/// </summary>
321+
private const byte VER_NT_DOMAIN_CONTROLLER = 0x0000002;
322+
323+
/// <summary>
324+
/// The operating system is Windows Server.
325+
/// </summary>
326+
/// <remarks>
327+
/// A server that is also a domain controller is reported as VER_NT_DOMAIN_CONTROLLER, not VER_NT_SERVER.
328+
/// </remarks>
329+
private const byte VER_NT_SERVER = 0x0000003;
330+
288331
#endregion
289332
}
290333

0 commit comments

Comments
 (0)