DSInternals/Src/DSInternals.PowerShell/Commands/Replication/AddADReplNgcKeyCommand.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

47 lines
1.5 KiB
C#

using System.Management.Automation;
using System.Security.Principal;
namespace DSInternals.PowerShell.Commands
{
[Cmdlet(VerbsCommon.Add, "ADReplNgcKey")]
[OutputType("None")]
public class AddADReplNgcKeyCommand : ADReplPrincipalCommandBase
{
// TODO: Change to X509Certificate2
[Parameter(Mandatory = true)]
[AcceptHexString]
public byte[] PublicKey
{
get;
set;
}
protected override void ProcessRecord()
{
switch (this.ParameterSetName)
{
case ParameterSetByGuid:
this.ReplicationClient.WriteNgcKey(this.ObjectGuid, this.PublicKey);
break;
case ParameterSetByDN:
this.ReplicationClient.WriteNgcKey(this.DistinguishedName, this.PublicKey);
break;
case ParameterSetByName:
this.ValidateDomainName();
this.ReplicationClient.WriteNgcKey(new NTAccount(this.Domain, this.SamAccountName), this.PublicKey);
break;
case ParameterSetBySid:
this.ReplicationClient.WriteNgcKey(this.ObjectSid, this.PublicKey);
break;
case ParameterSetByUPN:
this.ReplicationClient.WriteNgcKey(new NTAccount(this.UserPrincipalName), this.PublicKey);
break;
}
}
}
}