• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

Check age of network passwords

I'm admin of a 2003 server and would like to get a list of users and the age of their passwords (but not the passwords themselves). Is there a query i can run to obtain this information? How many different ways can you find out the age of a password? What about finding out when the password will expire? This information is obviously stored since the server knows when to notify people that their password is expiring. Thanks!
0
carrp
Asked:
carrp
1 Solution
 
oBdACommented:
The command
net user <Username> /domain
in a command window will give you the necessary information.
Here's a small script (it's not fast, but it should work) that creates a comma-separated list of the user names, when the password was last set, and when it expires. Simply adjust the domain information and the log file definition at the beginning.

====8<----[UserPwd.cmd]----
@echo off
setlocal
set LogFile=C:\Temp\UserPwd.log
set DNRoot=dc=your,dc=domain,dc=local

>"%LogFile%" echo Username, Password last set, Password expires
for /f "skip=1" %%a in ('dsquery user "%DNRoot%" ^| dsget user -samid') do call :process %%a
goto leave

:process
set User=%1
if /i "%User%"=="dsget" goto :eof
:: *** Localization: the first number in the "tokens=" must be set to the number of words
:: *** before the dates in the "password last set" and "password expires" lines.
for /f "tokens=3*" %%a in ('net user %User% /domain ^| find /i "Password last set"') do set PwdLastSet=%%b
for /f "tokens=2*" %%a in ('net user %User% /domain ^| find /i "Password expires"') do set PwdExpires=%%b
echo %User%: %PwdLastSet%, %PwdExpires%
>>"%LogFile%" echo %User%,%PwdLastSet%,%PwdExpires%
goto :eof

:leave
====8<----[UserPwd.cmd]----
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now