Find out if account is locked using terminal
I need to detect if a user has locked their account on Catalina ( for example by typing an incorrect password x times). Any ideas how can I do this?
You can use pwpolicy getaccountpolicies -u usershortname
- if the account is disabled it will return "Error: Credential verification failed because account is disabled."
For example:
[root@macOS] / #pwpolicy disableuser -u admin
Disabling account for user <admin>
[root@macOS] / #pwpolicy getaccountpolicies -u admin
Getting account policies for user <admin>
Error: Credential verification failed because account is disabled.
[root@macOS] / #pwpolicy enableuser -u admin
Enabling account for user <admin>
[root@macOS] / #pwpolicy getaccountpolicies -u admin
Getting account policies for user <admin>
[root@macOS] / #