How to validate DistinguishedName strings
By nature, Exchange 2007 is strongly integrated with Active Directory (AD) and as such, it exposes new types to interact with AD. A lot of the user object properties across all the AD forest are made available through the Get-User command-let.
If you need to pass strings as "DistinguishedName" this function can help you validate them.
function Validate-DistinguishedName{
param([string]$dn)
[Microsoft.Exchange.Data.Directory.ADObjectId]::IsValidDistinguishedName($dn)
}
>> Validate-DistinguishedName "CN=Administrator,CN=Users,DC=homelab,DC=loc"
True
>> Validate-DistinguishedName "CN=Administrator,CN=Users,DC=homelab"
True
True
>> Validate-DistinguishedName "Shay@homelab.loc"
False
>> Validate-DistinguishedName "AB=CD,EF= G H"
True
No comments:
Post a Comment