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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Agent Mode Engaged! Enchaining Agentic Operations with Splunk AI Assistant 2.0

    Are you ready to transform how your team handles complex data requests? We invite you to our upcoming ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...