<?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: How do I create a lookup with ldapsearch and use the lookup within the same search? in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263392#M30426</link>
    <description>&lt;P&gt;The ldapsearch query is pulling back all the hosts for a certain OU, and then I want to search the list of hosts to see if they're "talking"/reporting to Splunk. As @somesoni2 mentioned, having a scheduled search keep the host list updated would be a great alternative.&lt;/P&gt;</description>
    <pubDate>Wed, 25 May 2016 15:15:06 GMT</pubDate>
    <dc:creator>dpanych</dc:creator>
    <dc:date>2016-05-25T15:15:06Z</dc:date>
    <item>
      <title>How do I create a lookup with ldapsearch and use the lookup within the same search?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263388#M30422</link>
      <description>&lt;P&gt;My search is not returning any results..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source="/opt/splunk/var/log/splunk/metrics.log*" sourcetype="splunkd" fwdType="*"
 [|inputlookup Servers.csv | return 9999 $name] 
| dedup sourceHost 
| table hostname, sourceHost
| search [| ldapsearch basedn="OU=ABC,OU=Servers,OU=SMG,DC=ZZZ,DC=COM" search="(&amp;amp;(objectClass=computer))" attrs="name,distinguishedName" | table name | sort name | outputlookup Servers.csv]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here was my logic which doesn't work (brain is fried for the day):&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;ldapsearch queries ldap for the list of host names and creates a lookup&lt;/LI&gt;
&lt;LI&gt;The lookup is then used in the beginning of the search to find all hosts that are reporting to Splunk.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Does that seem correct?&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 23:30:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263388#M30422</guid>
      <dc:creator>dpanych</dc:creator>
      <dc:date>2016-05-24T23:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a lookup with ldapsearch and use the lookup within the same search?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263389#M30423</link>
      <description>&lt;P&gt;Why don't you run your ldapsearch query separately, as scheduled search, to generate lookup and then just use it in your regular search? I don't think it will be necessary but you can schedule the ldapsearch query to run more frequently if your server list can change rather frequently. &lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2016 23:49:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263389#M30423</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-05-24T23:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a lookup with ldapsearch and use the lookup within the same search?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263390#M30424</link>
      <description>&lt;P&gt;Assuming that the list of servers returned from the LDAP is a subset of the list of servers that are forwarding, you can use the LDAP to limit your search like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal source="/opt/splunk/var/log/splunk/metrics.log*" sourcetype="splunkd" fwdType="*"
[| ldapsearch basedn="OU=ABC,OU=Servers,OU=SMG,DC=ZZZ,DC=COM" search="(&amp;amp;(objectClass=computer))" attrs="name,distinguishedName" | dedup name | table name | rename name AS sourceHost ] 
| dedup sourceHost 
| table hostname, sourceHost
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There really is no reason to save this out to a lookup, at least no reason that you have given.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 07:24:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263390#M30424</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-25T07:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a lookup with ldapsearch and use the lookup within the same search?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263391#M30425</link>
      <description>&lt;P&gt;Your search, as explained, benefits not at all from the &lt;CODE&gt;ldapseaech&lt;/CODE&gt;.  As you have explained it (and attempted to implement), the base search is neither (usefully) qualified (limited) by the ldapsearch, nor is any extra host-related information added to the events from the ldapseach.  So just skip the ldapsearch entirely.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 07:24:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263391#M30425</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-05-25T07:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a lookup with ldapsearch and use the lookup within the same search?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263392#M30426</link>
      <description>&lt;P&gt;The ldapsearch query is pulling back all the hosts for a certain OU, and then I want to search the list of hosts to see if they're "talking"/reporting to Splunk. As @somesoni2 mentioned, having a scheduled search keep the host list updated would be a great alternative.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 15:15:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263392#M30426</guid>
      <dc:creator>dpanych</dc:creator>
      <dc:date>2016-05-25T15:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a lookup with ldapsearch and use the lookup within the same search?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263393#M30427</link>
      <description>&lt;P&gt;You can do a join, I use it to compare hosts in AD to Splunk for missing ones&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| ldapsearch search="(&amp;amp;(objectClass=user)(&amp;amp;(objectClass=computer)))" 
| table cn lastLogon description
| join type=left cn [
| inputlookup dmc_forwarder_assets | search os=Windows | table hostname, status, arch, last_connected
| rename hostname AS cn]
| eval epoch1day_ago=relative_time(now(), "-1d@d" ) 
| where (last_connected &amp;lt; epoch1day_ago OR isnull(last_connected) )
| eval last_connected=strftime('last_connected', "%c") 
| table cn,lastLogon,description,arch,last_connected,status
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Sep 2016 05:59:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/How-do-I-create-a-lookup-with-ldapsearch-and-use-the-lookup/m-p/263393#M30427</guid>
      <dc:creator>Simon_Mantell</dc:creator>
      <dc:date>2016-09-09T05:59:46Z</dc:date>
    </item>
  </channel>
</rss>

