Security

regex to pull cn fields

spluser1
Loves-to-Learn

Hey everyone, 

 

I have this format - 

cn=<name>,ou=<>,ou=people,dc=<>,dc=<>,dc=<> that i'm pulling that i need to use only the cn= field. how can i do it with the regex command? is that possible?

 

thanks!!

Labels (1)
0 Karma

spluser1
Loves-to-Learn

excellent, i see it now. works perfect. thanks!

0 Karma

isoutamo
SplunkTrust
SplunkTrust
As it solve you problem, please accept it as Solution so other can see it later.
Happy Splunking!
0 Karma

spluser1
Loves-to-Learn

thanks for the info.

when saying your existing field you mean to put the actual field that contain the format? also is there a way to save that so i could do a stats to show the output only with the cn value?

0 Karma

isoutamo
SplunkTrust
SplunkTrust
If you have extracted that whole value into some field (e.g. ldap_query) then use it. If that value is still in _raw then you could leave that field=xxxx part away. Just see https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Rex
0 Karma

isoutamo
SplunkTrust
SplunkTrust

Hi

you could use this

...
| rex field=<your existing field> "cn=(?<cn>[^,]+)"

r. Ismo

PS. regex101.com is excellent place to test these! 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...