feature: dont disable a computer account if a duplicate, commissioned device exists
This commit is contained in:
@@ -6,6 +6,7 @@ using Disco.Services.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
@@ -99,6 +100,14 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
public override void Applied(DiscoDataContext Database, Device Device, ref bool DeviceADDescriptionSet)
|
||||
{
|
||||
if (ActiveDirectory.IsValidDomainAccountId(Device.DeviceDomainId))
|
||||
{
|
||||
// Don't disable if another active device with the same name exists
|
||||
var duplicateNamedDevice = Database.Devices
|
||||
.Where(i => i.DeviceDomainId == Device.DeviceDomainId &&
|
||||
i.SerialNumber != Device.SerialNumber &&
|
||||
i.DecommissionedDate == null)
|
||||
.Any();
|
||||
if (!duplicateNamedDevice)
|
||||
{
|
||||
var adAccount = Device.ActiveDirectoryAccount();
|
||||
|
||||
@@ -131,6 +140,7 @@ namespace Disco.Services.Devices.Importing.Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override int? GuessColumn(DiscoDataContext Database, IDeviceImportContext Context, IDeviceImportDataReader DataReader)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user