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!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...