<?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 to obtain the user account from a user SID ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643470#M222894</link>
    <description>&lt;P&gt;appendpipe adds the subpipeline to the main search results. &amp;nbsp;You will get one row only if&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn​&lt;/LI-CODE&gt;&lt;P&gt;returns no result.&lt;/P&gt;&lt;P&gt;Maybe you can start by explaining what you are trying to achieve with the main search and the subpipe? &amp;nbsp;Is the sole purpose of the subpipe to provide cn? &amp;nbsp;If that is the purpose, you command is working exactly as you designed.&lt;/P&gt;&lt;P&gt;ldapfilter is not a standard SPL command. &amp;nbsp;So, it is not clear how it works with a dashboard token when the main search is not limited by the token. &amp;nbsp;Maybe your actual code is (objectSid=UserSID), i.e., with the UserSID returned from the main search, not with a token $UserSID$? &amp;nbsp;Or do you mean that you actually uses a token $UserSID$ that has the value of&amp;nbsp;S-1-5-21-2872280-2353677280-1887909603-18694, while the main search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1 AuthMethod=Bearer &lt;/LI-CODE&gt;&lt;P&gt;happens to also only return a single user&amp;nbsp;S-1-5-21-2872280-2353677280-1887909603-18694?&lt;/P&gt;&lt;P&gt;Either way, the result suggests that the magical command ldapfilter returns&amp;nbsp;last_connection, UserAgents, and totalConnections in addition to cn. &amp;nbsp;Is this possible? &amp;nbsp;For example, if you run&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval userSID = "S-1-5-21-2872280-2353677280-1887909603-18694"
| ldapfilter domain=LAB search="(objectSid=" . UserSID . ")" attrs=cn&lt;/LI-CODE&gt;&lt;P&gt;Does this give you&amp;nbsp;last_connection, UserAgents, and totalConnections as well?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 07:38:18 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-05-16T07:38:18Z</dc:date>
    <item>
      <title>How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643400#M222876</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am creating a query to identify users connected to our Exchange on-prem servers using Microsoft Modern Authentication.&lt;BR /&gt;So far I managed to get the user SID and using ldapfilter command I obtain the user account related to the SID but I get two rows for some reason.&lt;/P&gt;&lt;P&gt;Could someone point what could be the issue? or maybe a better way to reach the same goal.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1 AuthMethod=Bearer 
| stats count(_time) as totalConnections,earliest(_time) as lastcon,values(UserAgent) as UserAgents by UserSID
| eval last_connection = strftime(lastcon, "%Y%m%d")
| table UserSID,last_connection, UserAgents, totalConnections
| appendpipe 
 [| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn ]&lt;/LI-CODE&gt;&lt;P&gt;the result&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;UserSID	last_connection	UserAgents	totalConnections	cn
S-1-5-21-2872280-2353677280-1887909603-18694	20230515	Microsoft Office/16.0 (Windows NT 10.0; Microsoft Outlook 16.0.4266; Pro)	61	 
S-1-5-21-2872280-2353677280-1887909603-18694	20230515	Microsoft Office/16.0 (Windows NT 10.0; Microsoft Outlook 16.0.4266; Pro)	61	Josh Wright&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 15 May 2023 15:02:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643400#M222876</guid>
      <dc:creator>corti77</dc:creator>
      <dc:date>2023-05-15T15:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643470#M222894</link>
      <description>&lt;P&gt;appendpipe adds the subpipeline to the main search results. &amp;nbsp;You will get one row only if&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn​&lt;/LI-CODE&gt;&lt;P&gt;returns no result.&lt;/P&gt;&lt;P&gt;Maybe you can start by explaining what you are trying to achieve with the main search and the subpipe? &amp;nbsp;Is the sole purpose of the subpipe to provide cn? &amp;nbsp;If that is the purpose, you command is working exactly as you designed.&lt;/P&gt;&lt;P&gt;ldapfilter is not a standard SPL command. &amp;nbsp;So, it is not clear how it works with a dashboard token when the main search is not limited by the token. &amp;nbsp;Maybe your actual code is (objectSid=UserSID), i.e., with the UserSID returned from the main search, not with a token $UserSID$? &amp;nbsp;Or do you mean that you actually uses a token $UserSID$ that has the value of&amp;nbsp;S-1-5-21-2872280-2353677280-1887909603-18694, while the main search&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1 AuthMethod=Bearer &lt;/LI-CODE&gt;&lt;P&gt;happens to also only return a single user&amp;nbsp;S-1-5-21-2872280-2353677280-1887909603-18694?&lt;/P&gt;&lt;P&gt;Either way, the result suggests that the magical command ldapfilter returns&amp;nbsp;last_connection, UserAgents, and totalConnections in addition to cn. &amp;nbsp;Is this possible? &amp;nbsp;For example, if you run&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval userSID = "S-1-5-21-2872280-2353677280-1887909603-18694"
| ldapfilter domain=LAB search="(objectSid=" . UserSID . ")" attrs=cn&lt;/LI-CODE&gt;&lt;P&gt;Does this give you&amp;nbsp;last_connection, UserAgents, and totalConnections as well?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 07:38:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643470#M222894</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-16T07:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643476#M222895</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;thanks for your reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query aims to identify the list of authentication methods (Negotiate or Bearer) and the email clients used to connect to our Exchange on-prem deployment. The goal is to also get the last connection for each combination.&lt;/P&gt;&lt;P&gt;For that, I slightly changed the query to make it more simple.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1  
| stats latest(_time) as LastTime by UserSID,UserAgent,AuthMethod
| eval TimeConnection = strftime(LastTime, "%Y%m%d-%H:%M")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the results are&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;UserSID	TimeConnection	UserAgent	AuthMethod	
ATLAS-LAB\jcortijo	20230515-17:52	Microsoft Office/14.0 (Windows NT 6.2; Microsoft Outlook 14.0.7266; Pro)	Negotiate	
S-1-5-21-287652280-2353677280-1887909603-18694	20230515-17:39	Microsoft Office/16.0 (Windows NT 10.0; Microsoft Outlook 16.0.4266; Pro)	Bearer	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In cases of Bearer authentication, the userSID needs to be converted to a human-readable version, and that is when I would like to use ldapfilter or ldapserach.&lt;/P&gt;&lt;P&gt;I tried your query&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval userSID = "S-1-5-21-2872280-2353677280-1887909603-18694"
| ldapfilter domain=LAB search="(objectSid=" . UserSID . ")" attrs=cn&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it seems like the "." is not a valid operator.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;External search command 'ldapfilter' returned error code 1. Script output = "error_message=invalid filter ".&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 08:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643476#M222895</guid>
      <dc:creator>corti77</dc:creator>
      <dc:date>2023-05-16T08:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643565#M222931</link>
      <description>&lt;P&gt;Thanks for the explanation. &amp;nbsp;So, I see two parts in this question. &amp;nbsp;One is why/how ldapsearch command returns&amp;nbsp;&lt;SPAN&gt;last_connection, UserAgents, and totalConnections (in addition to cn), two is whether the full result meets your need.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Let me start with the second question. &amp;nbsp;If the goal is to return a human readable user name, is cn the best choice? &amp;nbsp;When autmethod is negotiate, UserSID is of the format &amp;lt;domain&amp;gt;\user ID. &amp;nbsp;Do you want to return/compose something similar?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If cn is sufficient for your purpose, and all you want is to have the row containing cn, all you need is&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1 AuthMethod=Bearer 
| stats count(_time) as totalConnections,earliest(_time) as lastcon,values(UserAgent) as UserAgents by UserSID
| eval last_connection = strftime(lastcon, "%Y%m%d")
| table UserSID,last_connection, UserAgents, totalConnections
| appendpipe 
 [| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn ]
| where isnotnull(cn)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first question is really a curiosity. &amp;nbsp;Since I really have no idea how the external command work, the test I proposed was purely a blind guess. &amp;nbsp;Maybe $UserSID$ is not at all a dashboard token as I interpreted? &amp;nbsp;Maybe the command substitutes $UserSID$ with the value of field UserSID?&lt;/P&gt;&lt;P&gt;You can always try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| ldapfilter domain=LAB search="(objectSid=$S-1-5-21-2872280-2353677280-1887909603-18694$)" attrs=cn&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval userSID = "S-1-5-21-2872280-2353677280-1887909603-18694"
| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval userSID = "S-1-5-21-2872280-2353677280-1887909603-18694"
| ldapfilter domain=LAB search="(objectSid=$" . UserSID . "$)" attrs=cn&lt;/LI-CODE&gt;&lt;P&gt;and see what comes out. &amp;nbsp;But I don't think the answer will help you reach your end result much.&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 06:52:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643565#M222931</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-17T06:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643574#M222935</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I was using a similar approach to eliminate duplicates generated by ldapfilter command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1   
| stats latest(_time) as LastTime by UserSID,UserAgent,AuthMethod
| appendpipe [| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn ] 
| search  cn=*&lt;/LI-CODE&gt;&lt;P&gt;The problem is that I have two types of events, one with a human-readable value domain\user and the SIDs.&lt;/P&gt;&lt;P&gt;With this command the tuples that are not SIDs are removed as the ldapfilter command returns nothing for them.&lt;/P&gt;&lt;P&gt;Do you know a way I could append a new column that simply replicates the UserSID in case follow the regex&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;^domain\\[a-zA-Z0-9_]+$&amp;nbsp;&lt;/STRONG&gt;and appends the output of ldapfilter otherwise? I tried with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1   
| stats latest(_time) as LastTime by UserSID,UserAgent,AuthMethod
| appendpipe 
   [| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn ] 
| eval new_column=if(match(UserSID, "^LAB\\[a-zA-Z0-9_]+$"), UserSID, cn)&lt;/LI-CODE&gt;&lt;P&gt;but the column "new_column" always appears empty.&lt;/P&gt;&lt;P&gt;Any idea on how to achieve this? Many thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 07:41:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643574#M222935</guid>
      <dc:creator>corti77</dc:creator>
      <dc:date>2023-05-17T07:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643723#M223000</link>
      <description>&lt;P&gt;If you want to combine results from the two AuthMethod, there's a simpler method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1
| stats max(_time) as LastTime by UserSID,UserAgent,AuthMethod
| appendpipe [| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn ]
| stats values(cn) as cn by UserSID,UserAgent,AuthMethod LastTime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;If you don't want to see that ugly UserSID when AuthMethod is bearer, you can even put cn into UserSID like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LABMX1
| stats max(_time) as LastTime by UserSID,UserAgent,AuthMethod
| appendpipe [| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn ]
| stats values(cn) as cn by UserSID,UserAgent,AuthMethod LastTime
| eval UserSID = coalesce(cn, UserSID)
| fields - cn&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 03:17:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643723#M223000</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-18T03:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643733#M223003</link>
      <description>&lt;P&gt;Yes! Thanks a lot . Coalesce, I forgot about that one &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Finally, I would like to group all the rows that belong to the same UserSID, I tried using stats list().&lt;/P&gt;&lt;P&gt;Is it correct? As I need to use one list() per field, I was wondering if the columns do not get mixed up.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=msexchange sourcetype=MSExchange:2016:WinHttp host=LAB
| stats latest(_time) as LastTime by UserSID,UserAgent,AuthMethod
| eval TimeConnection = strftime(LastTime, "%Y%m%d-%H:%M")
| appendpipe
[| ldapfilter domain=LAB search="(objectSid=$UserSID$)" attrs=cn ]
| stats values(cn) as cn by UserSID,UserAgent,AuthMethod, TimeConnection
| eval UserSID = coalesce(cn, UserSID)
| fields - cn
| stats list(UserAgent),list(AuthMethod), list(TimeConnection ) by UserSID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;thanks a lot once again&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 07:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643733#M223003</guid>
      <dc:creator>corti77</dc:creator>
      <dc:date>2023-05-18T07:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to obtain the user account from a user SID ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643795#M223026</link>
      <description>&lt;P&gt;In your use case, list is the way to go. &amp;nbsp;List preserves the order of rows, so multiple fields will be aligned properly across columns.&lt;/P&gt;&lt;P&gt;Given that UserSID with negotiate auth method and cn (with bearer) are drastically different, there is no chance the same user will have identical UserSID after coalesce. &amp;nbsp;As such, you can use AuthMethod as groupby and not run a list. (AuthMethod will have the same value listed twice for each UserSID.) &amp;nbsp;If you want to group by true user, a different LDAP attribute (or combination of attributes) will be needed instead of cn.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 14:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-obtain-the-user-account-from-a-user-SID/m-p/643795#M223026</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-18T14:53:18Z</dc:date>
    </item>
  </channel>
</rss>

