<?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: Verify if users are in an Active Directory group in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/532162#M150327</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I have been trying to do what you say whole week-end. I came with this but nothing seems to work, I'm not getting it to work.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| ldapsearch domain="default" search="(&amp;amp;(objectClass=group)(cn=GROUP_NAME))" 
| ldapgroup 
| append 
    [ ldapsearch domain="default" search="(&amp;amp;(objectClass=user))" attrs="sAMAccountName" 
    | rename sAMAccountName AS user 
    | fields user] 
| stats values(member_name) as member_name values(user) as user by Joinkey 
| eval result=if(match(member_name, user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;Can you give me an example of how I should do it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sasquatchatmars&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Dec 2020 09:28:24 GMT</pubDate>
    <dc:creator>Sasquatchatmars</dc:creator>
    <dc:date>2020-12-07T09:28:24Z</dc:date>
    <item>
      <title>Verify if users are in an Active Directory group</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/531866#M150240</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have been trying to create a search which compares results from an index with results from an ldap search. The goal is to check if a user is not one of the groups.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For now I have this query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="summary_wineventlog" cn=Group1 OR cn=Group1 OR cn=Group3 
| append [ | ldapsearch domain="default" search="(&amp;amp;(objectClass=user))" attrs="sAMAccountName" | rename sAMAccountName AS user | fields user]
| regex user!="^([a-zA-Z0-9_\.-]+)\$$"
| rex field=member_name "(?&amp;lt;username&amp;gt;\S+)+"
| eval result=if(match(username, user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The eval function only shows "Not contained".&amp;nbsp; My field member_name contains every user delimited with a white space. The weird thing is that the field username only shows every first username of the field member_name. So that field would look like this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;user1 user2 user3 user4 user5 user6 user7 user8&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have a lookup which contains a field with the usernames but I can't add it, every time i tried it gave me an error. This was the query that I tried for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="summary_wineventlog" cn=Group1 OR cn=Group2 OR cn=Group3
[| inputlookup account_status_tracker | fields user]
| regex user!="^([a-zA-Z0-9_\.-]+)\$$"
| rex field=member_name "(?&amp;lt;username&amp;gt;\S+)+"
| eval result=if(match(member_name, user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does someone know how I could check if a user is not in one of the 3 groups with one of the two searches above?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sasquatchatmars&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 14:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/531866#M150240</guid>
      <dc:creator>Sasquatchatmars</dc:creator>
      <dc:date>2020-12-03T14:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Verify if users are in an Active Directory group</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/531925#M150260</link>
      <description>&lt;P&gt;So the problem with this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="summary_wineventlog" cn=Group1 OR cn=Group1 OR cn=Group3 
| append [ | ldapsearch domain="default" search="(&amp;amp;(objectClass=user))" attrs="sAMAccountName" | rename sAMAccountName AS user | fields user]
| regex user!="^([a-zA-Z0-9_\.-]+)\$$"
| rex field=member_name "(?&amp;lt;username&amp;gt;\S+)+"
| eval result=if(match(username, user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is the &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; command puts the output of ldapsearch *below* the results for the base search.&amp;nbsp; The result is no event has both the user and member_name fields so they never match and result field is always "Not Contained".&amp;nbsp;&lt;/P&gt;&lt;P&gt;The solution, if you want to continue using &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt;, is to merge the two sets of results before comparing fields.&amp;nbsp; Do that using &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt;, provided you have a field common to both data sets on which to base the merge.&lt;/P&gt;&lt;P&gt;Regarding the second search,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="summary_wineventlog" cn=Group1 OR cn=Group2 OR cn=Group3
[| inputlookup account_status_tracker | fields user]
| regex user!="^([a-zA-Z0-9_\.-]+)\$$"
| rex field=member_name "(?&amp;lt;username&amp;gt;\S+)+"
| eval result=if(match(member_name, user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output from inputlookup will be added to the base search, resulting in a query that is not likely to produce the desired results.&amp;nbsp; Run the subsearch by itself with | format to see what I mean.&lt;/P&gt;&lt;P&gt;The fix for that is to modify the subsearch so it produces output that works with the base search.&amp;nbsp; You may want to add "NOT" before the subsearch so the query finds data in the summary index that is not in the lookup file.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 21:28:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/531925#M150260</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-12-03T21:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Verify if users are in an Active Directory group</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/531972#M150280</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I have been trying your suggestion but I can't quite seem to make it work. Would it be possible for you to correct the searches I have made so that I will have an example for futur references?&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the first one I tried to by renaming the member_name field to user in order to have a common field named user. Than by adding&amp;nbsp;| stats values(*) as * by user which would give&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| ldapsearch domain="default" search="(&amp;amp;(objectClass=group)(cn=GroupName))" 
| ldapgroup 
| append 
    [ ldapsearch domain="default" search="(&amp;amp;(objectClass=user))" attrs="sAMAccountName" 
    | rename sAMAccountName AS user 
    | regex user!="^([a-zA-Z0-9_\.-]+)\$$" 
    | search user!="$*" 
    | fields user] 
| stats values(*) as * by user 
| eval result=if((member_name=user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By the way I started using an ldapsearch as base search so that I'm sure I will always get the updated values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the second search I ran the | format command in the subsearch and uderstand want you mean. The problem is that I don't know how to modify the subsearch so that it will output normal results. Now it shows this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;( ( user="USER1" ) OR ( user="USER2" ) OR ( user="USER3" )OR ..... )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried to add the NOT before the subsearch but is it possible that this can't be used with an ldapsearch? Because I tried this and it gave me an error "Script execution failed for external search command 'ldapgroup'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| ldapsearch domain="default" search="(&amp;amp;(objectClass=group)(cn=EV_*))" 
| ldapgroup 
NOT [| inputlookup account_status_tracker 
    | fields user] 
| rex field=member_name "(?&amp;lt;username&amp;gt;\S+)+" 
| eval result=if(match(member_name, user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not working with splunk since a very long time so I'm still trying to learn, sorry if I may be asking basic questions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Sasquatchatmars&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 07:54:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/531972#M150280</guid>
      <dc:creator>Sasquatchatmars</dc:creator>
      <dc:date>2020-12-04T07:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Verify if users are in an Active Directory group</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/532028#M150295</link>
      <description>&lt;P&gt;Renaming member_name to user means you no longer have a member_name field to use in &lt;FONT face="courier new,courier"&gt;if(member_name=user)&lt;/FONT&gt;.&amp;nbsp; The two searches should be merged using a different common field so you preserve the member_name and user fields for comparison.&lt;/P&gt;&lt;P&gt;I'm not familiar with the ldapgroup command, but it appears it does not accept "NOT".&amp;nbsp; I don't know how to work around that.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Dec 2020 14:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/532028#M150295</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-12-04T14:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Verify if users are in an Active Directory group</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/532162#M150327</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I have been trying to do what you say whole week-end. I came with this but nothing seems to work, I'm not getting it to work.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| ldapsearch domain="default" search="(&amp;amp;(objectClass=group)(cn=GROUP_NAME))" 
| ldapgroup 
| append 
    [ ldapsearch domain="default" search="(&amp;amp;(objectClass=user))" attrs="sAMAccountName" 
    | rename sAMAccountName AS user 
    | fields user] 
| stats values(member_name) as member_name values(user) as user by Joinkey 
| eval result=if(match(member_name, user),"Contained","Not Contained")&lt;/LI-CODE&gt;&lt;P&gt;Can you give me an example of how I should do it?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sasquatchatmars&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 09:28:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/532162#M150327</guid>
      <dc:creator>Sasquatchatmars</dc:creator>
      <dc:date>2020-12-07T09:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Verify if users are in an Active Directory group</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/532197#M150342</link>
      <description>&lt;P&gt;You have the general idea, but I do not know your data so I can't suggest a field by which you can merge the events.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 13:47:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Verify-if-users-are-in-an-Active-Directory-group/m-p/532197#M150342</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-12-07T13:47:39Z</dc:date>
    </item>
  </channel>
</rss>

