Fix #141 preserve computer names for non-domain joined devices

This commit is contained in:
Gary Sharp
2024-01-11 16:27:40 +11:00
parent 974a07f3bb
commit 85d51c0e45
6 changed files with 44 additions and 33 deletions
+8 -1
View File
@@ -84,7 +84,14 @@ namespace Disco.Web.Controllers
{
try
{
m.Device.DeviceDomainId = ActiveDirectory.ParseDomainAccountId(m.Device.DeviceDomainId);
if (ActiveDirectory.IsValidDomainAccountId(m.Device.DeviceDomainId, out var accountUsername, out var accountDomain))
{
m.Device.DeviceDomainId = $@"{accountDomain.NetBiosName}\{accountUsername}";
}
else
{
ModelState.AddModelError("Device.DeviceDomainId", @"The computer name must be in the format 'DOMAIN\Username'");
}
}
catch (ArgumentException ex)
{