All Apps and Add-ons

Search for enabled users and last login time

mattvickers
Engager

Is there an easy way to search Splunk for an AD user account that is enabled and the time they last logged in with their account?

0 Karma

lukejadamec
Super Champion

It depends on which version of windows you're using and how you search

528 is the EventCode for W2k3 and 4624 is the EventCode for W2k8 and Win7. These event codes will be logged on the local system - not the domain controller. So, you would need forwarders on all systems in order to search the security logs. If you had a mix of systems the search would look like this:

EventCode=528 OR EventCode=4624 | eval Account_Name=mvindex(Account_Name,1) | eval UserAccount=coalesce(Account_Name,User_Name) |search NOT UserAccount="*$" NOT UserAccount=anonymous NOT UserAccount=system| dedup UserAccount |table _time,UserAccount,Workstation_Name

If you were just going to monitor the domain controller, then you want to monitor event code 4776 for W2k8.

(EventCode=4776 Error_Code=0x0) | dedup Logon_Account |table _time,Logon_Account,Source_Workstation

The dedup command will tell Splunk to grab the first match it sees, and drop the others, so that should be the most recent event per user.

lukejadamec
Super Champion

EventCode 626 means "account enabled". If you are looking for account changes, then you should do that in a separate search.

EventCode=626 |table Caller_User_Name, Target_Account_Name
The caller is the person who changed the account, and the target is the account that was changed.

0 Karma

mattvickers
Engager

Just one last thing - I'm still seeing disabled accounts. Could you show me how to integrate EventCode=626 into this search please?

0 Karma

mattvickers
Engager

Perfect - thanks!

0 Karma

lukejadamec
Super Champion

I added _time to the output.

0 Karma

lukejadamec
Super Champion

I exclude them. I'll update the answer.

0 Karma

mattvickers
Engager

Thank you lukejadamec!

Works nicely, but I see a lot of service accounts in there that I do not want to report on.

If I were to use:

EventCode=528 | eval Account_Name=mvindex(Account_Name,1) | eval UserAccount=coalesce(Account_Name,User_Name) | dedup UserAccount | table_time,UserAccount,Workstation_Name 

How would I specify AD accounts in a specific OU?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...