Splunk Search

How do I extract a certain OU from my DN in my active directory data?

DPWSplunkPOC
Explorer

I would like to extract a certain portion of my AD data to identify a certain OU. The OU I want to extract always appears before the ,ou=field. So, my data might look like this:

CN=username, OU=value1, OU=value2, OU=value3, ou=value4, dc=value5

But sometimes my data might include an extra OU=, so a simple pattern match does not work. For example another string may look like this:

CN=username, OU=value1, OU=value2, OU=value3, OU=value4, ou=value5, dc=value6

If I have those to strings I would want the regex to give me value3 from the first string and value4 from the second string.

The regex I have is close but is capturing between value,ou when looking at OU=value,ou=value

Here is the regex I developed so far:

\bOU\b=(\w+)?(?P< agency >),ou

0 Karma
1 Solution

DPWSplunkPOC
Explorer

I figured it out.

\bOU\b=(\w+)?(?P< agency >\w{2}),ou

View solution in original post

0 Karma

DPWSplunkPOC
Explorer

I figured it out.

\bOU\b=(\w+)?(?P< agency >\w{2}),ou

0 Karma
Get Updates on the Splunk Community!

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...