Splunk Search

How do I filter events based on LDAP search results?

hayduk
Path Finder

Hi guys,

I would like to Filter Events based on the result of a LDAP search. Especially, I would like to get all Password Reset Events for Smartcard-only Users in my Active Directory Domain.

I have the SPL for the Smartcard-only Users:

    | ldapsearch search="(&(objectclass=user)(!(objectClass=computer))(userAccountControl:1.2.840.113556.1.4.803:=262144))"

So, I got a list of all users that have Smartcard-only Flag set.

I also have the query for a Password Reset successful Events:

index="wineventlog" source="WinEventLog:Security" TaskCategory="User Account Management" EventCode=4724 

So, I get all Events with Password Reset attempts.

But how can I merge them together, so I only get the Events from Smartcard-only Users? I have to match the sAMAccountName AD Attribute with the Account_Name Field of the Events.

I don’t get it on my own, so maybe someone can give me a hint how the achieve the requested result?

0 Karma
1 Solution

gcusello
Legend

Hi hayduk,
I haven't an ldap to test, anyway you have to use the ldap search in a subsearch, something like this:

 index="wineventlog" source="WinEventLog:Security" TaskCategory="User Account Management" EventCode=4724 [ | ldapsearch search="(&(objectclass=user)(!(objectClass=computer))(userAccountControl:1.2.840.113556.1.4.803:=262144))" | fields user ]

the main thing to check is that the field name is the same both in main search and ldapsearch, if it's different use the rename command.

Remember that ldapsearch is slow, if you haven't many changes, you could schedule your ldapsearch and put results in a lookup, then use this lookup.

Bye.
Giuseppe

View solution in original post

0 Karma

gcusello
Legend

Hi hayduk,
I haven't an ldap to test, anyway you have to use the ldap search in a subsearch, something like this:

 index="wineventlog" source="WinEventLog:Security" TaskCategory="User Account Management" EventCode=4724 [ | ldapsearch search="(&(objectclass=user)(!(objectClass=computer))(userAccountControl:1.2.840.113556.1.4.803:=262144))" | fields user ]

the main thing to check is that the field name is the same both in main search and ldapsearch, if it's different use the rename command.

Remember that ldapsearch is slow, if you haven't many changes, you could schedule your ldapsearch and put results in a lookup, then use this lookup.

Bye.
Giuseppe

0 Karma

hayduk
Path Finder

Thank You! It worked as You descibed. The correct query would be:
index="wineventlog" source="WinEventLog:Security" TaskCategory="User Account Management" EventCode=4724 [| ldapsearch search="(&(objectclass=user)(!(objectClass=computer))(userAccountControl:1.2.840.113556.1.4.803:=262144))"
| fields sAMAccountName
| rename sAMAccountName as Account_Name]

0 Karma
Get Updates on the Splunk Community!

This Week's Community Digest - Splunk Community Happenings [9.26.22]

Get the latest news and updates from the Splunk Community here! Upcoming User Group Events! 👏 Check ...

BSides Splunk 2022 - The Call for Papers is now Open!

TLDR; Main Site: https://bsidessplunk.com CFP Site: https://bsidessplunk.com/cfp CFP Opens: December 15th, ...

Sending Metrics to Splunk Enterprise With the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...