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
Get Updates on the Splunk Community!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...