<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: parse elements of a DN in Security</title>
    <link>https://community.splunk.com/t5/Security/parse-elements-of-a-DN/m-p/62392#M2075</link>
    <description>&lt;P&gt;Most often, Splunk will auto-extract some parts of the DN. Format3 is most likely auto-extracted because of key value pairs. Format 2 is probably a near impossibility, since the data presented is probably of variable length, so extraction without separators won't happen. Format 1 could probably be done with a regex: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;your_Search | rex field=_raw "CN=(?&amp;lt;cn&amp;gt;[\w\d\s]+)" | rex field=_raw "OU=(?&amp;lt;org_unit&amp;gt;[^=]*)="|eval ou = substr(org_unit,-2)| rex field=_raw "O=(?&amp;lt;o_unit&amp;gt;[^=])="|eval o = substr(o_unit,-2)| stats count values(ou) by cn, o&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The evals are necessary because the matching will capture "OU" from the next string, prior to the =. All of these rex's could be put into props/tranforms to make the searches cleaner. &lt;/P&gt;</description>
    <pubDate>Thu, 13 Dec 2012 13:49:25 GMT</pubDate>
    <dc:creator>alacercogitatus</dc:creator>
    <dc:date>2012-12-13T13:49:25Z</dc:date>
    <item>
      <title>parse elements of a DN</title>
      <link>https://community.splunk.com/t5/Security/parse-elements-of-a-DN/m-p/62391#M2074</link>
      <description>&lt;P&gt;In some logs i have ldap DNs which i want to slice a part out from it like the CN or the PATH without the DN. The DNs i have get potentially in different formats.&lt;/P&gt;

&lt;P&gt;Format 1:&lt;BR /&gt;
O=xxx\OU=yyy\OU=zzz\CN=xyz&lt;/P&gt;

&lt;P&gt;Format 2:&lt;BR /&gt;
\xxx\yyy\zzz&lt;/P&gt;

&lt;P&gt;Format 3:&lt;BR /&gt;
CN=xyz,OU=zzz,OU=yyy,O=xxx&lt;/P&gt;

&lt;P&gt;I would like to parse the elements and get all elements minus the first one etc.&lt;/P&gt;

&lt;P&gt;I presume a custom command or macro could help there but i really really hope someone has done something similar.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2012 13:24:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/parse-elements-of-a-DN/m-p/62391#M2074</guid>
      <dc:creator>dominiquevocat</dc:creator>
      <dc:date>2012-12-13T13:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: parse elements of a DN</title>
      <link>https://community.splunk.com/t5/Security/parse-elements-of-a-DN/m-p/62392#M2075</link>
      <description>&lt;P&gt;Most often, Splunk will auto-extract some parts of the DN. Format3 is most likely auto-extracted because of key value pairs. Format 2 is probably a near impossibility, since the data presented is probably of variable length, so extraction without separators won't happen. Format 1 could probably be done with a regex: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;your_Search | rex field=_raw "CN=(?&amp;lt;cn&amp;gt;[\w\d\s]+)" | rex field=_raw "OU=(?&amp;lt;org_unit&amp;gt;[^=]*)="|eval ou = substr(org_unit,-2)| rex field=_raw "O=(?&amp;lt;o_unit&amp;gt;[^=])="|eval o = substr(o_unit,-2)| stats count values(ou) by cn, o&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The evals are necessary because the matching will capture "OU" from the next string, prior to the =. All of these rex's could be put into props/tranforms to make the searches cleaner. &lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2012 13:49:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/parse-elements-of-a-DN/m-p/62392#M2075</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2012-12-13T13:49:25Z</dc:date>
    </item>
  </channel>
</rss>

