I have a nomenclature to respect while performing some tasks against the Active Directory.
Here's the nomenclature:
- TT-EEE-Mnemonic: if TT = 'GA' or 'GS' or 'PA' or 'PF' -> the schema to create is a "group", with a groupScope of Global.
- LT-EEE-Mnemonic: if T = 'A' or 'G' or 'I' or 'N' or 'P' -> the schema to create is a "group", with a groupScope of Domain local.
- TTT-EEE-Mnemonic: if TTT* = 'CNX' or 'GST' or 'SVC' -> the shema to create is an "user"
- T-SSSS-Mnemonic: if T = 'A' or 'L' or 'M' or 'R' or 'S' -> the schema to create is an "organizationUnit"
What I'm after is a simpler and more effective way than this:
If(dn.Substring(3, 2).Contains("GA") _
Or variable.Substring(3, 2).Contains("GS") _
Or dn.Substring(3, 2).Contains("PA") _
Or dn.Substring(3, 2).Contains("PF")) Then
schema = "group" ' Global'
Else If(dn.Substring(4, 1).Contains("A") _
Or dn.Substring(4, 1).Contains("G") _
Or dn.Substring(4, 1).Contains("I") _
Or dn.Substring(4, 1).Contains("N") _
Or dn.Substring(4, 1).Contains("P")) Then
schema = "group" ' Local'
Else If(dn.Substring(3, 3).Contains("CNX") _
' Well... You get the idea, don't you?
End If
I guess I could use a RegularExpression
, or perhaps one for each of the nomenclature I got, something alike.
Is there a way a RegularExpression
could become handy in this situation? Or would it be best to stick with that old big-If? Any suggestions are welcome.
Sorry for asking, but I'm not used to use RegularExpression
. I know they exist, and bit of what they can do, but that's all.
Thanks!