fix #135 avoid failing device import/enrol when unable to set AD description
This commit is contained in:
@@ -5,6 +5,7 @@ using Disco.Services.Authorization;
|
||||
using Disco.Services.Documents;
|
||||
using Disco.Services.Expressions;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Logging;
|
||||
using Disco.Services.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -188,9 +189,16 @@ namespace Disco.Services
|
||||
if (ActiveDirectory.IsValidDomainAccountId(d.DeviceDomainId))
|
||||
{
|
||||
var adMachineAccount = ActiveDirectory.RetrieveADMachineAccount(d.DeviceDomainId);
|
||||
try
|
||||
{
|
||||
if (adMachineAccount != null)
|
||||
adMachineAccount.SetDescription(d);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemLog.LogWarning($"Unable to update AD Machine Account Description for {d.DeviceDomainId}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
return newDua;
|
||||
}
|
||||
|
||||
@@ -579,12 +579,19 @@ namespace Disco.Services.Devices.Enrolment
|
||||
if (adMachineAccount != null && !adMachineAccount.IsCriticalSystemObject)
|
||||
{
|
||||
EnrolmentLog.LogSessionProgress(sessionId, 75, "Updating Active Directory Computer Account Properties");
|
||||
try
|
||||
{
|
||||
// Use non-Wlan Adapter with fastest speed
|
||||
var macAddress = Request.Hardware?.NetworkAdapters?.Where(na => !na.IsWlanAdapter).OrderByDescending(na => na.Speed).Select(na => na.MACAddress).FirstOrDefault();
|
||||
adMachineAccount.UpdateNetbootGUID(Request.Hardware.UUID, macAddress);
|
||||
if (RepoDevice.AssignedUser != null)
|
||||
adMachineAccount.SetDescription(RepoDevice);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
EnrolmentLog.LogSessionWarning(sessionId, $"Unable to update AD Machine Account attributes: {ex.Message}");
|
||||
}
|
||||
}
|
||||
if (RepoDevice.DeviceProfile.DistributionType == DeviceProfile.DistributionTypes.OneToOne)
|
||||
{
|
||||
if (RepoDevice.AssignedUser == null)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Devices.Importing;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Logging;
|
||||
using Disco.Services.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -146,8 +147,16 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
var adAccount = Device.ActiveDirectoryAccount();
|
||||
|
||||
if (adAccount != null && !adAccount.IsCriticalSystemObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
adAccount.SetDescription(Device);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemLog.LogWarning($"Unable to update AD Machine Account Description for {Device.DeviceDomainId}: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
DeviceADDescriptionSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Devices.Importing;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -115,8 +116,16 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
}
|
||||
|
||||
if (!DeviceADDescriptionSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
adAccount.SetDescription(Device);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemLog.LogWarning($"Unable to update AD Machine Account Description for {Device.DeviceDomainId}: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
DeviceADDescriptionSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Devices.Importing;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -119,8 +120,16 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
}
|
||||
|
||||
if (!DeviceADDescriptionSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
adAccount.SetDescription(Device);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemLog.LogWarning($"Unable to update AD Machine Account Description for {Device.DeviceDomainId}: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
DeviceADDescriptionSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Devices.Importing;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -93,8 +94,16 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
var adAccount = Device.ActiveDirectoryAccount();
|
||||
|
||||
if (adAccount != null && !adAccount.IsCriticalSystemObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
adAccount.SetDescription(Device);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemLog.LogWarning($"Unable to update AD Machine Account Description for {Device.DeviceDomainId}: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
DeviceADDescriptionSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Devices.Importing;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -89,8 +90,16 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
var adAccount = Device.ActiveDirectoryAccount();
|
||||
|
||||
if (adAccount != null && !adAccount.IsCriticalSystemObject)
|
||||
{
|
||||
try
|
||||
{
|
||||
adAccount.SetDescription(Device);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SystemLog.LogWarning($"Unable to update AD Machine Account Description for {Device.DeviceDomainId}: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
DeviceADDescriptionSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user