v1.3.1 - Add Initialize override that calls Register() to hook into page rendering
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.UI.Device;
|
using Disco.Models.UI.Device;
|
||||||
using Disco.Services.Interop.ActiveDirectory;
|
using Disco.Services.Interop.ActiveDirectory;
|
||||||
using Disco.Services.Plugins;
|
using Disco.Services.Plugins;
|
||||||
@@ -11,6 +12,11 @@ namespace Disco.Plugins.ADCompare.Features
|
|||||||
[PluginFeature(Id = "ADCompareDeviceUI", Name = "Device Page - AD Compare")]
|
[PluginFeature(Id = "ADCompareDeviceUI", Name = "Device Page - AD Compare")]
|
||||||
public class DeviceUIExtension : UIExtensionFeature<DeviceShowModel>
|
public class DeviceUIExtension : UIExtensionFeature<DeviceShowModel>
|
||||||
{
|
{
|
||||||
|
public override void Initialize(DiscoDataContext Database)
|
||||||
|
{
|
||||||
|
Register();
|
||||||
|
}
|
||||||
|
|
||||||
public override UIExtensionResult ExecuteAction(ControllerContext context, DeviceShowModel model)
|
public override UIExtensionResult ExecuteAction(ControllerContext context, DeviceShowModel model)
|
||||||
{
|
{
|
||||||
var device = model.Device;
|
var device = model.Device;
|
||||||
@@ -41,10 +47,8 @@ namespace Disco.Plugins.ADCompare.Features
|
|||||||
var hasManagedBy = !string.IsNullOrEmpty(managedByDN);
|
var hasManagedBy = !string.IsNullOrEmpty(managedByDN);
|
||||||
var hasAssignment = !string.IsNullOrEmpty(discoAssignedUser);
|
var hasAssignment = !string.IsNullOrEmpty(discoAssignedUser);
|
||||||
|
|
||||||
// Extract display name from managedBy DN
|
|
||||||
string managedByDisplayName = hasManagedBy ? ExtractCNFromDN(managedByDN) : null;
|
string managedByDisplayName = hasManagedBy ? ExtractCNFromDN(managedByDN) : null;
|
||||||
|
|
||||||
// Look up the Disco assigned user's DN in AD for comparison
|
|
||||||
string assignedUserDN = null;
|
string assignedUserDN = null;
|
||||||
if (hasAssignment)
|
if (hasAssignment)
|
||||||
{
|
{
|
||||||
@@ -57,7 +61,6 @@ namespace Disco.Plugins.ADCompare.Features
|
|||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare DN-to-DN
|
|
||||||
bool isMatch = false;
|
bool isMatch = false;
|
||||||
if (!hasAssignment && !hasManagedBy)
|
if (!hasAssignment && !hasManagedBy)
|
||||||
isMatch = true;
|
isMatch = true;
|
||||||
@@ -107,7 +110,6 @@ namespace Disco.Plugins.ADCompare.Features
|
|||||||
}
|
}
|
||||||
html.Append("</td></tr>");
|
html.Append("</td></tr>");
|
||||||
|
|
||||||
// Last Logon
|
|
||||||
var lastLogonTicks = adAccount.GetPropertyValue<long>("lastLogonTimestamp");
|
var lastLogonTicks = adAccount.GetPropertyValue<long>("lastLogonTimestamp");
|
||||||
html.Append("<tr><td><strong>Last Login</strong></td><td>");
|
html.Append("<tr><td><strong>Last Login</strong></td><td>");
|
||||||
if (lastLogonTicks > 0)
|
if (lastLogonTicks > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user