Splunk Search

I need help with rex ad DN field.

karu0711
Communicator

my DN field value "cn=jsuwus, jkhzdhkjc,ou=sdsfefv accounts,ou=ffdsrew users,dc=hgsywy,dc=tre,dc=hyt,dc=kuhytr"
I need rex to extract anything after "="and end ",ou=" if it see "=" need to stop two letter and "," so in this instance
cn field as "first_field" value="jsuwus, jkhzdhkjc" 
ou field as "2_field" value="sdsfefv accounts"
ou field as "3_field" value="ffdsrew users"
dc field as "4_field" value="hgsywy"
dc field as "5_field" value="tre"
dc field as "6_field" value="hyt"
dc field as "7_field" value=kuhytr"

Thanks in advance

Labels (2)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

OK. Let me stop you right there.

1. It is of course a DN - it has its fields. Why do you want to lose that information?

2. Remember that LDAP DN can have properly escaped commas or equal signs.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| makeresults
| eval dn="cn=jsuwus, jkhzdhkjc,ou=sdsfefv accounts,ou=ffdsrew users,dc=hgsywy,dc=tre,dc=hyt,dc=kuhytr"
| rex field=dn "cn=(?<cn>[^=]+)(?<!,)(?<!o)(?<!u)"
| rex field=dn max_match=0 "ou=(?<ou>[^=]+)(?<!,)(?<!o|d)(?<!u|c)"
| rex field=dn max_match=0 "dc=(?<dc>[^=]+)(?<!,)(?<!d)(?<!c)"
0 Karma
Get Updates on the Splunk Community!

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...