DSInternals/Src/DSInternals.PowerShell/Commands/Base/ADReplPrincipalCommandBase.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

81 lines
2.2 KiB
C#

using System.Management.Automation;
using System.Security.Principal;
namespace DSInternals.PowerShell.Commands
{
public abstract class ADReplPrincipalCommandBase : ADReplObjectCommandBase
{
protected const string ParameterSetByName = "ByName";
protected const string ParameterSetByUPN = "ByUPN";
protected const string ParameterSetBySid = "BySID";
#region Parameters
[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipelineByPropertyName = true,
ParameterSetName = ParameterSetByName
)]
[ValidateNotNullOrEmpty]
[Alias("Login", "sam", "AccountName", "User")]
public string SamAccountName
{
get;
set;
}
[Parameter(
Mandatory = true,
Position = 1,
ValueFromPipelineByPropertyName = true,
ParameterSetName = ParameterSetByName
)]
[ValidateNotNullOrEmpty]
[Alias("AccountDomain", "UserDomain")]
public string Domain
{
get;
set;
}
[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = ParameterSetByUPN
)]
[ValidateNotNullOrEmpty]
[Alias("UPN")]
public string UserPrincipalName
{
get;
set;
}
[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
ParameterSetName = ParameterSetBySid
)]
[ValidateNotNullOrEmpty]
[Alias("Sid")]
public SecurityIdentifier ObjectSid
{
get;
set;
}
#endregion Parameters
protected void ValidateDomainName()
{
if (this.Domain.Contains("."))
{
// This is not a hard check, because dots are actually allowed in NetBIOS names, although not recommended.
// TODO: Extract as a resource
this.WriteWarning("The domain name supplied appears to be a DNS name instead of NetBIOS name.");
}
}
}
}