All Apps and Add-ons

Field names with hyphens

jpayne
Explorer

Some of the attribute names I would like to retrieve with the ldapfilter command include hyphens. As splunk field names cannot contain hyphens, the naive:

ldapfilter domain=FOO search="(&(objectClass=User)(sAMAccountname=$user$))" attrs="title,department,my-custom-attribute"

Doesn't work. How can I get this data out?

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

You would do a rename before the mvindex, for example. It's good practice to not have operators as part of field names, writing | eval foo = bar-baz would set foo to the difference between bar and baz, not to the value of a single field called bar-baz.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

You would do a rename before the mvindex, for example. It's good practice to not have operators as part of field names, writing | eval foo = bar-baz would set foo to the difference between bar and baz, not to the value of a single field called bar-baz.

ahardy42
Engager

An example with rename my-custom-attr would be great

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Splunk field names in general can (but really shouldn't!) contain hyphens:

| stats count | eval my-custom-attr = "foo"

Must be something related to the ldapfilter command then. What happens if you leave off the attrs= parameter?

jpayne
Explorer

I was misremembering the issue. The attributes from ldapfilter need a eval fooattr=mvindex(attribute,-1) in order to get them to display. That mvindex doesn't work with a hyphen in the field name.

Turns out that the custom attribute isn't one of them, so my efforts were unneeded. But out of curiosity, how would one address this? mvindex(my-custom-attribute,-1)

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

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...