This topic contains 2 replies, has 2 voices, and was last updated by
June 21, 2018 at 8:07 am #102892ParticipantPoints: 0Rank: Member
I would like to know if it is possible to use Recursive Regular Expression Or if there is a regular expression that check for LDAP filter syntax.
To be more specific I am looking for a LDAP filter syntax regex in order to add it as a ValidatePattern Validation Attribute
Param ( [parameter(Mandatory=$true)] [ValidatePattern("(\s*\((?:[&|]\s*RECURSIVE+|(?:!\s*RECURSIVE)|[a-zA-Z][a-zA-Z0-9-]*[~]?=[^()]*)\s*\)\s*)")] [String] $LDAPFIlter )
LDAP Syntax Filter
I found this in perl:
But it is using recursive pattern (?1)+ . I think it is to get the correct amount of parenthesis.
I see that python as an addition to it that will allow the "recursive " parts.
Thank you in advance for your time.
June 21, 2018 at 1:58 pm #102913ParticipantPoints: 8Rank: Member
Just wondering, why not sure a regular -filter, which is either powershell or sql syntax?
June 22, 2018 at 8:23 am #103003ParticipantPoints: 0Rank: Member
Yes thanks, I suppose that even if System.DirectoryServices.DirectorySearcher is used , the LDAP filter needs a specific format like "(&(objectCategory=User)(Department=IT))" or "(&(sAMAccountName< =a)(!(sAMAccountName=$*)))" ref for AD : https://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx
The validation would be to confirm if the filter format is correct or not.
For SQL syntax , this is not possible unfortunately. This is not an AD. Just LDAP.
The topic ‘PowerShell: Recursive Regular Expression’ is closed to new replies.