mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-04-26 04:48:34 +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
81 lines
2.2 KiB
C#
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.");
|
|
}
|
|
}
|
|
}
|
|
}
|