mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-04-21 22:46:12 +00:00
61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
namespace DSInternals.PowerShell.Commands
|
|
{
|
|
using System;
|
|
using System.Management.Automation;
|
|
using DSInternals.DataStore;
|
|
|
|
public abstract class ADDBObjectCommandBase : ADDBCommandBase
|
|
{
|
|
protected const string parameterSetByGuid = "ByGuid";
|
|
protected const string parameterSetByDN = "ByDN";
|
|
|
|
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = parameterSetByDN)]
|
|
[ValidateNotNullOrEmpty]
|
|
[Alias("dn")]
|
|
public string DistinguishedName
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = parameterSetByGuid)]
|
|
[ValidateNotNullOrEmpty]
|
|
[Alias("Guid")]
|
|
public Guid ObjectGuid
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
protected DirectoryAgent DirectoryAgent
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
protected override void BeginProcessing()
|
|
{
|
|
base.BeginProcessing();
|
|
try
|
|
{
|
|
this.DirectoryAgent = new DirectoryAgent(this.DirectoryContext);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorRecord error = new ErrorRecord(ex, "TableOpenError", ErrorCategory.OpenError, null);
|
|
// Terminate on this error:
|
|
this.ThrowTerminatingError(error);
|
|
}
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && this.DirectoryAgent != null)
|
|
{
|
|
this.DirectoryAgent.Dispose();
|
|
this.DirectoryAgent = null;
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
} |