<?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: Regex for Windows username null values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65138#M16121</link>
    <description>&lt;P&gt;@cphair, I think I understand your question, maybe. if you know username and domain will always appear together.  If you wanted to preform multiple field extractions in the statment you might want to use the |(pipe) to make the match optional. Keep in mind that using the |(pipe) following alternative will be tried if the regex backtraces into the group.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Sep 2012 22:14:52 GMT</pubDate>
    <dc:creator>bmacias84</dc:creator>
    <dc:date>2012-09-19T22:14:52Z</dc:date>
    <item>
      <title>Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65131#M16114</link>
      <description>&lt;P&gt;I have a Windows event below. This regex, (?ms)^\s+User Name:\s+(?&lt;USER_NAME&gt;\S+), is used to extract the value from the User Name field which works great when there's a username available. Otherwise, in the event below when the User Name is blank, the regex picks up "Domain:" as the username. I'm trying to figure out what to add in the regex to prevent a value from being extracted if the User Name field is null.  &lt;/USER_NAME&gt;&lt;/P&gt;

&lt;P&gt;09/06/2012 08:54:52 AM&lt;BR /&gt;
LogName=Security&lt;BR /&gt;
SourceName=Security&lt;BR /&gt;
EventCode=529&lt;BR /&gt;
EventType=16&lt;BR /&gt;
Type=Failure Audit&lt;BR /&gt;
ComputerName=TESTSYSTEM&lt;BR /&gt;
User=SYSTEM&lt;BR /&gt;
Sid=S-1-5-18&lt;BR /&gt;
SidType=1&lt;BR /&gt;
Category=2&lt;BR /&gt;
CategoryString=Logon/Logoff&lt;BR /&gt;
RecordNumber=50947147&lt;BR /&gt;
Message=Logon Failure:&lt;BR /&gt;
    Reason:     Unknown user name or bad password&lt;BR /&gt;
    User Name:&lt;BR /&gt;&lt;BR /&gt;
    Domain:&lt;BR /&gt;&lt;BR /&gt;
    Logon Type: 3&lt;BR /&gt;
    Logon Process:  NtLmSsp &lt;BR /&gt;
    Authentication Package: NTLM&lt;BR /&gt;
    Workstation Name:&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2012 18:20:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65131#M16114</guid>
      <dc:creator>tpowell12</dc:creator>
      <dc:date>2012-09-19T18:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65132#M16115</link>
      <description>&lt;P&gt;The following regex statement should work.  I tested it with a few variation of your example.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?ms)^\s+User\sName:\s+(?P&amp;lt;user_name&amp;gt;[^\s]+|)
 OR
(?ms)^\s+User\sName:\s+(?P&amp;lt;user_name&amp;gt;[^\s]+|)\r
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps.&lt;/P&gt;

&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2012 18:58:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65132#M16115</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2012-09-19T18:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65133#M16116</link>
      <description>&lt;P&gt;It works with the \r at the end in an editor like gskinner.com/regexr. In Splunk, I have two extractions for one sourcetype. One for the username that you helped with and another for account names. The problem I have now is when I add the \r to regex in transforms.conf, the username is no longer extracted, only the account name. I must be missing something.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2012 20:57:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65133#M16116</guid>
      <dc:creator>tpowell12</dc:creator>
      <dc:date>2012-09-19T20:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65134#M16117</link>
      <description>&lt;P&gt;props.conf&lt;BR /&gt;
[tcp-raw]&lt;BR /&gt;
REPORT-extract_names = extract_username, extract_accountname&lt;/P&gt;

&lt;P&gt;transforms.conf &lt;BR /&gt;
[extract_username]&lt;BR /&gt;
- extracts the user name field in Windows security logs&lt;BR /&gt;
REGEX = (?ms)^\s+User Name:\s+([^\s]+|)\r&lt;BR /&gt;
FORMAT = user_name::$1&lt;/P&gt;

&lt;P&gt;[extract_accountname]&lt;BR /&gt;
- extracts the account name field in Windows security logs&lt;BR /&gt;
REGEX = (?ms)Account For Which Logon Failed.+?Account Name:\s+(\V+)&lt;BR /&gt;
FORMAT = account_name::$1&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65134#M16117</guid>
      <dc:creator>tpowell12</dc:creator>
      <dc:date>2020-09-28T12:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65135#M16118</link>
      <description>&lt;P&gt;Can you provide a sample of the event extract_accountname is used in?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2012 21:13:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65135#M16118</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2012-09-19T21:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65136#M16119</link>
      <description>&lt;P&gt;@bmacias84, if you know the Message format is always the same, can you add "Domain:" to the end of your regex, after the parentheses?  Do you really need to perform multi- and single-line matching for a username extraction?&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2012 21:28:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65136#M16119</guid>
      <dc:creator>cphair</dc:creator>
      <dc:date>2012-09-19T21:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65137#M16120</link>
      <description>&lt;P&gt;Ok,  I think I understand what you are trying to do and the following regex statement should work or at the very least get you most of the way there.&lt;/P&gt;

&lt;P&gt;(?m)^\s+(User\sName:\s+(?P&lt;USER_NAME&gt;[^\s]+|))|(?:Account\sFor\sWhich\sLogon\sFailed\s+Account\sName:\s+(?P&lt;ACCOUNT_NAME&gt;[^\s]+))\r&lt;/ACCOUNT_NAME&gt;&lt;/USER_NAME&gt;&lt;/P&gt;

&lt;P&gt;OR&lt;/P&gt;

&lt;P&gt;(?m)^\s+((?:User\sName:\s+(?P&lt;USER_NAME&gt;[^\s]+|))|(?:Account\sFor\sWhich\sLogon\sFailed\s+Account\sName:\s+(?P&lt;ACCOUNT_NAME&gt;[^\s]+|)))\r&lt;/ACCOUNT_NAME&gt;&lt;/USER_NAME&gt;&lt;/P&gt;

&lt;P&gt;Your Formate notation:&lt;BR /&gt;
FORMAT = account_name::$1 account_name::$2&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:28:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65137#M16120</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2020-09-28T12:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for Windows username null values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65138#M16121</link>
      <description>&lt;P&gt;@cphair, I think I understand your question, maybe. if you know username and domain will always appear together.  If you wanted to preform multiple field extractions in the statment you might want to use the |(pipe) to make the match optional. Keep in mind that using the |(pipe) following alternative will be tried if the regex backtraces into the group.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2012 22:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-Windows-username-null-values/m-p/65138#M16121</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2012-09-19T22:14:52Z</dc:date>
    </item>
  </channel>
</rss>

