feature: enrol devices bound to another domain

This commit is contained in:
Gary Sharp
2025-09-18 17:05:40 +10:00
parent deaac0f073
commit 356762c811
10 changed files with 605 additions and 222 deletions
@@ -34,6 +34,7 @@ namespace Disco.Web.Areas.API.Controllers
private const string pEnforceComputerNameConvention = "enforcecomputernameconvention";
private const string pEnforceOrganisationalUnit = "enforceorganisationalunit";
private const string pProvisionADAccount = "provisionadaccount";
private const string pProvisionFromOtherDomain = "provisionfromotherdomain";
private const string pAssignedUserLocalAdmin = "assigneduserlocaladmin";
private const string pSetAssignedUserForLogon = "setassigneduserforlogon";
private const string pAllowUntrustedReimageJobEnrolment = "allowuntrustedreimagejobrnrolment";
@@ -93,6 +94,9 @@ namespace Disco.Web.Areas.API.Controllers
case pProvisionADAccount:
UpdateProvisionADAccount(deviceProfile, value);
break;
case pProvisionFromOtherDomain:
UpdateProvisionFromOtherDomain(deviceProfile, value);
break;
case pAssignedUserLocalAdmin:
UpdateAssignedUserLocalAdmin(deviceProfile, value);
break;
@@ -351,6 +355,13 @@ namespace Disco.Web.Areas.API.Controllers
return Update(id, pProvisionADAccount, ProvisionADAccount, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceProfile.Configure)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult UpdateProvisionFromOtherDomain(int id, string ProvisionFromOtherDomain = null, bool? redirect = null)
{
return Update(id, pProvisionFromOtherDomain, ProvisionFromOtherDomain, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceProfile.Configure)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult UpdateSetAssignedUserForLogon(int id, string setAssignedUserForLogon = null, bool? redirect = null)
@@ -666,6 +677,18 @@ namespace Disco.Web.Areas.API.Controllers
throw new Exception("Invalid Boolean Value");
}
private void UpdateProvisionFromOtherDomain(DeviceProfile deviceProfile, string provisionFromOtherDomain)
{
if (bool.TryParse(provisionFromOtherDomain, out var bValue))
{
deviceProfile.ProvisionFromOtherDomain = bValue;
Database.SaveChanges();
return;
}
throw new Exception("Invalid Boolean Value");
}
private void UpdateAssignedUserLocalAdmin(DeviceProfile deviceProfile, string assignedUserLocalAdmin)
{
if (bool.TryParse(assignedUserLocalAdmin, out var bValue))
@@ -229,6 +229,35 @@
</p>
</div>
</div>
<div style="margin-top: 8px;">
@if (canConfig)
{
<input id="DeviceProfile_ProvisionFromOtherDomain" type="checkbox" @(Model.DeviceProfile.ProvisionFromOtherDomain ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty)) />
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceProfile_ProvisionFromOtherDomain'),
null,
'@Url.Action(MVC.API.DeviceProfile.UpdateProvisionFromOtherDomain(Model.DeviceProfile.Id))',
'ProvisionFromOtherDomain'
);
});
</script>
}
else
{
<input id="DeviceProfile_ProvisionFromOtherDomain" type="checkbox" @(Model.DeviceProfile.ProvisionFromOtherDomain ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty)) disabled="disabled" />
}
<label for="DeviceProfile_ProvisionFromOtherDomain">
Provision from another Domain
</label>
@AjaxHelpers.AjaxLoader()
<div class="info-box">
<p class="fa-p">
<i class="fa fa-info-circle"></i>When enabled, devices joined to another domain will be enrolled. Based on other policies this may change the domain they are bound to (eg. Provision Active Directory Account)
</p>
</div>
</div>
<div style="margin-top: 8px;">
@if (canConfig)
{
File diff suppressed because it is too large Load Diff