mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-04-27 05:18:19 +00:00
- Added the UserPrincipalName parameter to Get-ADReplAccount cmdlet - Improved DRS_MSG_GETCHGREQ_V8 delete - Fixed Set-ADDBBootKey cmdlet output type - Fixed some formatting inconsistencies
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
namespace DSInternals.PowerShell.Commands
|
|
{
|
|
using System;
|
|
using System.Management.Automation;
|
|
using DSInternals.SAM;
|
|
using DSInternals.SAM.Interop;
|
|
|
|
public abstract class LsaPolicyCommandBase : PSCmdlet, IDisposable
|
|
{
|
|
protected LsaPolicy LsaPolicy
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
#region Parameters
|
|
[Parameter(Mandatory = false, Position = 1)]
|
|
[Alias("Server", "ServerName", "Computer", "Machine", "MachineName", "System", "SystemName")]
|
|
[ValidateNotNullOrEmpty]
|
|
public string ComputerName
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
#endregion Parameters
|
|
|
|
#region Cmdlet Overrides
|
|
|
|
protected override void BeginProcessing()
|
|
{
|
|
// TODO: Extract as resource:
|
|
string serverName = this.ComputerName ?? "localhost";
|
|
this.WriteDebug(string.Format("Connecting to LSA service running on {0}.", serverName));
|
|
// TODO: Exception handling (process error category)
|
|
this.LsaPolicy = new LsaPolicy(this.ComputerName, this.RequiredAccessMask);
|
|
}
|
|
#endregion Cmdlet Overrides
|
|
|
|
protected abstract LsaPolicyAccessMask RequiredAccessMask
|
|
{
|
|
get;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
System.GC.SuppressFinalize(this);
|
|
}
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
{
|
|
if (disposing && this.LsaPolicy != null)
|
|
{
|
|
this.LsaPolicy.Dispose();
|
|
this.LsaPolicy = null;
|
|
}
|
|
}
|
|
}
|
|
}
|