<?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: Users that have not logged into Active Directory within X amount of days in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462091#M79770</link>
    <description>&lt;P&gt;@to4kawa Thank you for the help with your response! It took me awhile to get back to this, due to other projects. After many different variations of my logic I ended up only searching one index, which resolved my issue along with your suggestion.  Below is the latest version of the script which is working as desired. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar (OU="Vendor - Long Term" OR OU="Vendor - Short Term" OR OU="Vendor - VPN") lastLogonTimestamp* 
| fields cn, lastLogonTimestamp, userPrincipalName, userAccountControl, accountExpires, OU,distinguishedName
| dedup cn

| rex field=distinguishedName "(?&amp;lt;AccountType&amp;gt;(?&amp;lt;=OU=)(.*)(?=,OU=Vendor))"

| eval last_logon = strptime(lastLogonTimestamp, "%H:%M.%S %p, %a %m/%d/%Y") 
| where last_logon &amp;lt; relative_time(now(),"-14d@d")

| eval last_logon_date =strftime(strptime(lastLogonTimestamp,"%I:%M.%S %p, %a %m/%d/%Y"),"%Y/%m/%d")

| eval NetworkID = trim(replace(userPrincipalName, "@g1net.com", ""))

| eval uac = case(userAccountControl==66050,"Disabled, password never expires",userAccountControl==512,"Enable Account",userAccountControl==514,"Disable Account",userAccountControl==544,"Account Enabled - Require user to change password at first logon",userAccountControl==4096,"Workstation/Server",userAccountControl==66048,"Enabled, password never expires",userAccountControl==66050,"Disabled, password never expires",userAccountControl==262656,"Smart Card Logon Required",userAccountControl==532480,"Domain Controller",userAccountControl==1,"Script",userAccountControl==2,"Account Disabled",userAccountControl==16,"Locked Out",userAccountControl==512,"Normal Account",userAccountControl==8388608,"Password Expired",userAccountControl==8,"Home Directory Required",userAccountControl==32,"Password Not Require",userAccountControl==64,"Password Can't Change",userAccountControl==128,"Encrypted Text Password Allowed",userAccountControl==256,"Temp Duplicate Account",userAccountControl==2048,"Interdomain Trusted Account",userAccountControl==4096,"Workstation Tusted Account",userAccountControl==8192,"Server Trusted Account",userAccountControl==65536,"Don't Expire Password",userAccountControl==131072,"MNS Logon Account",userAccountControl==262144,"Smartcard Required",userAccountControl==524288,"Trusted for delegation",userAccountControl==1048576,"Not Delegated",userAccountControl==2097152,"Use Des Key Only",userAccountControl==4194304,"Don't Req Preauth",userAccountControl==16777216,"Trusted to auth for delegation")

| rename cn as "Name" NetworkID as "Network ID"  AccountType as "Vendor Type" uac as "Account Status" last_logon_date as "Last Logon" accountExpires as "Account Expires"
| table "Network ID" Name "Vendor Type" "Last Logon" "Account Expires" "Account Status"  | sort "Vendor Type", "Last Logon"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 16 Jan 2020 16:39:56 GMT</pubDate>
    <dc:creator>lbrhyne</dc:creator>
    <dc:date>2020-01-16T16:39:56Z</dc:date>
    <item>
      <title>Users that have not logged into Active Directory within X amount of days</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462087#M79766</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;We need to monitor a group of users within a specific security group and alert if they have not logged in within X amount of days. &lt;BR /&gt;
&lt;STRONG&gt;Our criteria&lt;/STRONG&gt; &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Users are contained within specific security groups.&lt;/LI&gt;
&lt;LI&gt;Need to return Group Name, Display Name, Last login, account status&lt;/LI&gt;
&lt;LI&gt;Only users who have not logged in within X amount of days from within the specific group&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;We are able to return items 1 and 2 but are having challenges getting return last login greater than X amount of days.&lt;/P&gt;

&lt;P&gt;Any help is greatly appreciated!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=wineventlog source="wineventlog:security"  action=success (EventCode=4624 OR EventCode=4634 OR EventCode=4779 OR EventCode=4800 OR EventCode=4801 OR EventCode=4802 OR EventCode=4803 OR EventCode=4804 ) (Logon_Type=2 OR Logon_Type=7 OR Logon_Type=10)) OR (index=msad sourcetype=ActiveDirectory userPrincipalName=*)
| fields memberOf,lastLogonTimestamp,userPrincipalName,description,userAccountControl,user,displayName,department
| eval acctname = trim(replace(userPrincipalName, "@host.com", ""))
| eval user=coalesce(user,acctname) | stats values(*) AS * BY user | search acctname=* user=*
| eval uac = case(userAccountControl==66050,"Disabled, password never expires",userAccountControl==512,"Enable Account",userAccountControl==514,"Disable Account",userAccountControl==544,"Account Enabled - Require user to change password at first logon",userAccountControl==4096,"Workstation/Server",userAccountControl==66048,"Enabled, password never expires",userAccountControl==66050,"Disabled, password never expires",userAccountControl==262656,"Smart Card Logon Required",userAccountControl==532480,"Domain Controller",userAccountControl==1,"Script",userAccountControl==2,"Account Disabled",userAccountControl==16,"Locked Out",userAccountControl==512,"Normal Account",userAccountControl==8388608,"Password Expired",userAccountControl==8,"Home Directory Required",userAccountControl==32,"Password Not Require",userAccountControl==64,"Password Can't Change",userAccountControl==128,"Encrypted Text Password Allowed",userAccountControl==256,"Temp Duplicate Account",userAccountControl==2048,"Interdomain Trusted Account",userAccountControl==4096,"Workstation Tusted Account",userAccountControl==8192,"Server Trusted Account",userAccountControl==65536,"Don't Expire Password",userAccountControl==131072,"MNS Logon Account",userAccountControl==262144,"Smartcard Required",userAccountControl==524288,"Trusted for delegation",userAccountControl==1048576,"Not Delegated",userAccountControl==2097152,"Use Des Key Only",userAccountControl==4194304,"Don't Req Preauth",userAccountControl==16777216,"Trusted to auth for delegation")
| rex field=memberOf  "(?&amp;lt;Classification&amp;gt;(\(CG\)(.*?,)))"
| eval Classification = trim(replace(Classification,",",""))
| eval blanks=if(Classification!="",Classification,"No Classification")
| stats values(blanks) as Classification values(displayName) as "Display Name" values(lastLogonTimestamp) as "Last Login" values(uac) as "Account Status" by acctname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Dec 2019 22:57:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462087#M79766</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2019-12-13T22:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Users that have not logged into Active Directory within X amount of days</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462088#M79767</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| stats values(blanks) as Classification values(displayName) as "Display Name" values(lastLogonTimestamp) as "Last Login" values(uac) as "Account Status" by acctname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;please provide this results.(sample)&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 00:59:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462088#M79767</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-14T00:59:27Z</dc:date>
    </item>
    <item>
      <title>Re: Users that have not logged into Active Directory within X amount of days</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462089#M79768</link>
      <description>&lt;P&gt;Thanks for the response @to4kawa!&lt;BR /&gt;
&lt;STRONG&gt;Display Name | Classification | Last Login Date &amp;gt; 60 Days | Account Status&lt;/STRONG&gt;&lt;BR /&gt;
Jon Doe               |AD Security Group |        12/1/2019               |                  Disabled&lt;/P&gt;

&lt;P&gt;The goal is to alert our help desk with this information so a ticket can be opened. We will probably have the alert run once a day.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2019 20:21:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462089#M79768</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2019-12-16T20:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Users that have not logged into Active Directory within X amount of days</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462090#M79769</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;your search 
| stats values(blanks) as Classification values(displayName) as "Display Name" values(lastLogonTimestamp) as "Last Login" values(uac) as "Account Status" by acctname
|eval last_login=strptime('Last Login',"%m/%d/%Y")
|where last_login &amp;lt; relative_time(now(),"-60d@d")
|table  "Display Name" Classification  "Last Login"  "Account Status" 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Dec 2019 11:36:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462090#M79769</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-12-17T11:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Users that have not logged into Active Directory within X amount of days</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462091#M79770</link>
      <description>&lt;P&gt;@to4kawa Thank you for the help with your response! It took me awhile to get back to this, due to other projects. After many different variations of my logic I ended up only searching one index, which resolved my issue along with your suggestion.  Below is the latest version of the script which is working as desired. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=foo sourcetype=bar (OU="Vendor - Long Term" OR OU="Vendor - Short Term" OR OU="Vendor - VPN") lastLogonTimestamp* 
| fields cn, lastLogonTimestamp, userPrincipalName, userAccountControl, accountExpires, OU,distinguishedName
| dedup cn

| rex field=distinguishedName "(?&amp;lt;AccountType&amp;gt;(?&amp;lt;=OU=)(.*)(?=,OU=Vendor))"

| eval last_logon = strptime(lastLogonTimestamp, "%H:%M.%S %p, %a %m/%d/%Y") 
| where last_logon &amp;lt; relative_time(now(),"-14d@d")

| eval last_logon_date =strftime(strptime(lastLogonTimestamp,"%I:%M.%S %p, %a %m/%d/%Y"),"%Y/%m/%d")

| eval NetworkID = trim(replace(userPrincipalName, "@g1net.com", ""))

| eval uac = case(userAccountControl==66050,"Disabled, password never expires",userAccountControl==512,"Enable Account",userAccountControl==514,"Disable Account",userAccountControl==544,"Account Enabled - Require user to change password at first logon",userAccountControl==4096,"Workstation/Server",userAccountControl==66048,"Enabled, password never expires",userAccountControl==66050,"Disabled, password never expires",userAccountControl==262656,"Smart Card Logon Required",userAccountControl==532480,"Domain Controller",userAccountControl==1,"Script",userAccountControl==2,"Account Disabled",userAccountControl==16,"Locked Out",userAccountControl==512,"Normal Account",userAccountControl==8388608,"Password Expired",userAccountControl==8,"Home Directory Required",userAccountControl==32,"Password Not Require",userAccountControl==64,"Password Can't Change",userAccountControl==128,"Encrypted Text Password Allowed",userAccountControl==256,"Temp Duplicate Account",userAccountControl==2048,"Interdomain Trusted Account",userAccountControl==4096,"Workstation Tusted Account",userAccountControl==8192,"Server Trusted Account",userAccountControl==65536,"Don't Expire Password",userAccountControl==131072,"MNS Logon Account",userAccountControl==262144,"Smartcard Required",userAccountControl==524288,"Trusted for delegation",userAccountControl==1048576,"Not Delegated",userAccountControl==2097152,"Use Des Key Only",userAccountControl==4194304,"Don't Req Preauth",userAccountControl==16777216,"Trusted to auth for delegation")

| rename cn as "Name" NetworkID as "Network ID"  AccountType as "Vendor Type" uac as "Account Status" last_logon_date as "Last Logon" accountExpires as "Account Expires"
| table "Network ID" Name "Vendor Type" "Last Logon" "Account Expires" "Account Status"  | sort "Vendor Type", "Last Logon"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jan 2020 16:39:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462091#M79770</guid>
      <dc:creator>lbrhyne</dc:creator>
      <dc:date>2020-01-16T16:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Users that have not logged into Active Directory within X amount of days</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462092#M79771</link>
      <description>&lt;P&gt;providing final query, it is useful and eazy to understand how to resolve the problem.&lt;BR /&gt;
Thank You, @lbrhyne&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 00:16:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Users-that-have-not-logged-into-Active-Directory-within-X-amount/m-p/462092#M79771</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-17T00:16:41Z</dc:date>
    </item>
  </channel>
</rss>

