I’m trying to remove the relative distinguished name from the AD distinguished name so that I can compare the container a user is in, to where they should be.
Originally I thought I could just use the split and use the comma as the parser. However I found that the RDN on some accounts have a comma within them such as CN=Howard, James,OU=corp,DC=example,DC=com, so I can’t parse using the comma.
How, or can I use regex and what would that look like?
I have tried something like: {"cn=[^,]+(?=,OU=)", "")) but I don’t know if velocity supports regex and if I can use this. I want to remove “CN=Howard, James,” but keep “OU=corp,DC=example,DC=com”.
Hi Fred,
I think you don’t need to really use regex - as it might be a bit complex. I’d suggest to make a substring based on index of “OU=” part. Something like that