Device enrolment with no model information
An exception was previously thrown when a device lacking manufacturer/model information attempted to enrol.
This commit is contained in:
@@ -59,6 +59,10 @@ namespace Disco.Client.Interop
|
||||
// Ignore
|
||||
// Indicates 'Wlanapi.dll' isn't present (ie. Servers)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve Wireless NetworkAdapter information from WlanApi", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<WirelessProfile> GetWirelessProfiles()
|
||||
@@ -96,6 +100,10 @@ namespace Disco.Client.Interop
|
||||
// Indicates 'Wlanapi.dll' isn't present (ie. Servers)
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to retrieve Wireless Profiles from WlanApi", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<WirelessProfile> GetWirelessProfiles(IntPtr wlanHandle)
|
||||
@@ -346,7 +354,10 @@ namespace Disco.Client.Interop
|
||||
// Indicates 'Wlanapi.dll' isn't present (ie. Servers)
|
||||
// Ignore policies
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Disco Client was unable to apply Wireless Profile Changes using WlanApi", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Description(this WLAN_INTERFACE_STATE State)
|
||||
|
||||
@@ -50,6 +50,21 @@ namespace Disco.Services
|
||||
|
||||
public static Tuple<DeviceModel, bool> GetOrCreateDeviceModel(this DbSet<DeviceModel> DeviceModelsSet, string Manufacturer, string Model, string ModelType)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Manufacturer))
|
||||
Manufacturer = "Unknown";
|
||||
else
|
||||
Manufacturer = Manufacturer.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Model))
|
||||
Model = "Unknown";
|
||||
else
|
||||
Model = Model.Trim();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(ModelType))
|
||||
ModelType = null;
|
||||
else
|
||||
ModelType = ModelType.Trim();
|
||||
|
||||
// Already Exists?
|
||||
var deviceModel = DeviceModelsSet.FirstOrDefault(dm => dm.Manufacturer == Manufacturer && dm.Model == Model);
|
||||
if (deviceModel == null)
|
||||
@@ -65,12 +80,19 @@ namespace Disco.Services
|
||||
// Create the Device Model in a different DataContext so we don't have to commit unrelated changes
|
||||
using (DiscoDataContext database = new DiscoDataContext())
|
||||
{
|
||||
var description = $"{Manufacturer} {Model}";
|
||||
|
||||
if (Model.Equals("Unknown", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
description = $"Unknown {Manufacturer} Model";
|
||||
}
|
||||
|
||||
var addDeviceModel = new DeviceModel
|
||||
{
|
||||
Manufacturer = Manufacturer,
|
||||
Model = Model,
|
||||
ModelType = ModelType,
|
||||
Description = string.Format("{0} {1}", Manufacturer, Model)
|
||||
Description = description
|
||||
};
|
||||
database.DeviceModels.Add(addDeviceModel);
|
||||
database.SaveChanges();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
public static MacSecureEnrolResponse MacSecureEnrol(DiscoDataContext Database, string Host)
|
||||
{
|
||||
MacEnrol trustedRequest = new MacEnrol();
|
||||
string sessionId = System.Guid.NewGuid().ToString("B");
|
||||
string sessionId = Guid.NewGuid().ToString("B");
|
||||
MacSecureEnrolResponse MacSecureEnrol;
|
||||
try
|
||||
{
|
||||
@@ -191,7 +191,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
string sessionId;
|
||||
if (OpenSessionId == null)
|
||||
{
|
||||
sessionId = System.Guid.NewGuid().ToString("B");
|
||||
sessionId = Guid.NewGuid().ToString("B");
|
||||
EnrolmentLog.LogSessionStarting(sessionId, Request.DeviceSerialNumber, EnrolmentTypes.Mac);
|
||||
}
|
||||
else
|
||||
@@ -221,7 +221,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
EnrolmentLog.LogSessionTaskAddedDevice(sessionId, Request.DeviceSerialNumber);
|
||||
DeviceProfile deviceProfile = Database.DeviceProfiles.Find(Database.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId);
|
||||
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.DeviceManufacturer.Trim(), Request.DeviceModel.Trim(), Request.DeviceModelType.Trim());
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.DeviceManufacturer, Request.DeviceModel, Request.DeviceModelType);
|
||||
DeviceModel deviceModel = deviceModelResult.Item1;
|
||||
if (deviceModelResult.Item2)
|
||||
EnrolmentLog.LogSessionTaskCreatedDeviceModel(sessionId, Request.DeviceSerialNumber, deviceModelResult.Item1.Manufacturer, deviceModelResult.Item1.Model);
|
||||
@@ -245,7 +245,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
EnrolmentLog.LogSessionProgress(sessionId, 50, "Existing Device, Updating Disco Instance");
|
||||
EnrolmentLog.LogSessionTaskUpdatingDevice(sessionId, Request.DeviceSerialNumber);
|
||||
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.DeviceManufacturer.Trim(), Request.DeviceModel.Trim(), Request.DeviceModelType.Trim());
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.DeviceManufacturer, Request.DeviceModel, Request.DeviceModelType);
|
||||
DeviceModel deviceModel = deviceModelResult.Item1;
|
||||
if (deviceModelResult.Item2)
|
||||
EnrolmentLog.LogSessionTaskCreatedDeviceModel(sessionId, Request.DeviceSerialNumber, deviceModelResult.Item1.Manufacturer, deviceModelResult.Item1.Model);
|
||||
@@ -313,7 +313,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
return domain.GetAvailableDomainController(RequireWritable: true);
|
||||
});
|
||||
|
||||
string sessionId = System.Guid.NewGuid().ToString("B");
|
||||
string sessionId = Guid.NewGuid().ToString("B");
|
||||
response.SessionId = sessionId;
|
||||
|
||||
EnrolmentLog.LogSessionStarting(sessionId, Request.SerialNumber, EnrolmentTypes.Normal);
|
||||
@@ -396,7 +396,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
DeviceProfile deviceProfile = Database.DeviceProfiles.Find(Database.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId);
|
||||
|
||||
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.Hardware.Manufacturer.Trim(), Request.Hardware.Model.Trim(), Request.Hardware.ModelType.Trim());
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.Hardware.Manufacturer, Request.Hardware.Model, Request.Hardware.ModelType);
|
||||
DeviceModel deviceModel = deviceModelResult.Item1;
|
||||
if (deviceModelResult.Item2)
|
||||
EnrolmentLog.LogSessionTaskCreatedDeviceModel(sessionId, Request.SerialNumber, deviceModelResult.Item1.Manufacturer, deviceModelResult.Item1.Model);
|
||||
@@ -432,7 +432,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
EnrolmentLog.LogSessionProgress(sessionId, 30, "Existing Device, Updating Disco Instance");
|
||||
EnrolmentLog.LogSessionTaskUpdatingDevice(sessionId, Request.SerialNumber);
|
||||
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.Hardware.Manufacturer.Trim(), Request.Hardware.Model.Trim(), Request.Hardware.ModelType.Trim());
|
||||
var deviceModelResult = Database.DeviceModels.GetOrCreateDeviceModel(Request.Hardware.Manufacturer, Request.Hardware.Model, Request.Hardware.ModelType);
|
||||
DeviceModel deviceModel = deviceModelResult.Item1;
|
||||
if (deviceModelResult.Item2)
|
||||
EnrolmentLog.LogSessionTaskCreatedDeviceModel(sessionId, Request.SerialNumber, deviceModelResult.Item1.Manufacturer, deviceModelResult.Item1.Model);
|
||||
|
||||
Reference in New Issue
Block a user