SEBWIN-717, #637: Fixed loading of MAC address for system info.

This commit is contained in:
Damian Büchel 2023-07-31 15:19:31 +02:00
parent b36df9ad5a
commit d76dbf6b40

View file

@ -219,11 +219,8 @@ namespace SafeExamBrowser.SystemComponents
try try
{ {
using (var searcher = new ManagementObjectSearcher("SELECT MACAddress FROM Win32_NetworkAdapterConfiguration WHERE DNSDomain IS NOT NULL")) using (var searcher = new ManagementObjectSearcher("SELECT MACAddress FROM Win32_NetworkAdapterConfiguration WHERE DNSHostName IS NOT NULL"))
using (var results = searcher.Get()) using (var results = searcher.Get())
{
if (results != default && results.Count > 0)
{
using (var networkAdapter = results.Cast<ManagementObject>().First()) using (var networkAdapter = results.Cast<ManagementObject>().First())
{ {
foreach (var property in networkAdapter.Properties) foreach (var property in networkAdapter.Properties)
@ -235,15 +232,9 @@ namespace SafeExamBrowser.SystemComponents
} }
} }
} }
else finally
{ {
MacAddress = UNDEFINED; MacAddress = MacAddress ?? UNDEFINED;
}
}
}
catch (Exception)
{
MacAddress = UNDEFINED;
} }
} }