DSInternals/Src/DSInternals.PowerShell/Commands/Base/LsaPolicyCommandBase.cs
Michael Grafnetter 85b48b32df - Added the Add-ADReplNgcKey cmdlet
- Added the UserPrincipalName parameter to Get-ADReplAccount cmdlet
- Improved DRS_MSG_GETCHGREQ_V8 delete
- Fixed Set-ADDBBootKey cmdlet output type
- Fixed some formatting inconsistencies
2019-08-24 23:07:57 +02:00

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;
}
}
}
}