mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-04-21 06:26:05 +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
77 lines
1.8 KiB
C#
77 lines
1.8 KiB
C#
using System;
|
|
using System.Management.Automation;
|
|
using System.Net;
|
|
using DSInternals.Replication;
|
|
|
|
namespace DSInternals.PowerShell.Commands
|
|
{
|
|
public abstract class ADReplCommandBase : PSCmdlet, IDisposable
|
|
{
|
|
|
|
#region Parameters
|
|
[Parameter(Mandatory = true)]
|
|
[ValidateNotNullOrEmpty]
|
|
[Alias("Host", "DomainController", "DC")]
|
|
public string Server
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Parameter(Mandatory = false)]
|
|
[ValidateNotNull]
|
|
public PSCredential Credential
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Parameter(Mandatory = false)]
|
|
[ValidateNotNull]
|
|
[Alias("Proto", "RPCProtocol", "NCACN")]
|
|
public RpcProtocol Protocol
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
#endregion Parameters
|
|
|
|
protected DirectoryReplicationClient ReplicationClient
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
#region Cmdlet Overrides
|
|
|
|
protected override void BeginProcessing()
|
|
{
|
|
NetworkCredential netCredential = null;
|
|
if(this.Credential != null)
|
|
{
|
|
// Convert PSCredential to NetworkCredential
|
|
netCredential = this.Credential.GetNetworkCredential();
|
|
}
|
|
|
|
this.ReplicationClient = new DirectoryReplicationClient(this.Server, this.Protocol, netCredential);
|
|
}
|
|
|
|
#endregion Cmdlet Overrides
|
|
|
|
public void Dispose()
|
|
{
|
|
this.Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
{
|
|
if (disposing && this.ReplicationClient != null)
|
|
{
|
|
this.ReplicationClient.Dispose();
|
|
this.ReplicationClient = null;
|
|
}
|
|
}
|
|
}
|
|
}
|