Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Userid report from ADS to a .txt file 3

Status
Not open for further replies.

sneeland

MIS
Jan 27, 2004
49
US
I'm struggling trying to create a report from ADS data that contains some basic userid info. I need to run the pgm from something like a .bat pgm and it will output the results to a .txt or other format file. I don't want to run this interactivly since I plan on setting it up as a nightly batch job.

Values I specifically need are:

Userid
User Name
Description
Date account was created
Last Login Date

Once I see how this works I can adjust further. I've been running the ADDUSERS utility from the resource kit but it doesn't give me the Create Date. I'm trying to calculate inactivity periods for userids for possible removal.

Thanks so much!!!

Steve
 
I believe you can use DSQUERY and DSGET to get any attribute.
commands can be quite complex (at least i think so) but theres plenty of help on ms site.
first command you wanna do is: dsquery user /? for the user object part.

you can bat the DS tool set or make vbscript to do the job.

brgds Nicolai

 
You can also look at csvde (Comma Seperated Values Data Extract). It dumps fields from AD to a text file.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
C:\WINDOWS>dsquery user -inactive 13
dsquery failed:The parameter is incorrect.:Windows could not run this query because
use you are connected to a domain that does not support this query.
type dsquery /? for help.

Other DSQUERY parms work, just not the INACTIVE one. COuld not get A?D custom query report to list Inactive userids either.
 
The correct syntax for dsquery would be:

[blue]dsquery user domainroot -inactive 13[/blue]

As MRDenny suggests, csvde can dump the information you are looking for...

[blue]csvde -f c:\userdump.csv -l "sAMAccountName,displayName,description,createTimeStamp,lastLogonTimestamp" -r "(&(objectClass=user)(objectCategory=person))"[/blue]

That will dump you the list, but then you will have to convert the Integer8Date numbers that you get in the "lastLogonTimestamp" field. That can be done with VBScript or the "w32tm /ntte" command.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
The first CreateDate displayed is: 20030913175425.0Z

When I issue w32tm command from dos prmpt I get:

C:\WINDOWS>w32tm /ntte 20030913175425.0Z
23 04:24:51.3175425 - 1/23/1601 11:24:51 PM (local time)

C:\WINDOWS>w32tm /ntte 20030913175425
23 04:24:51.3175425 - 1/23/1601 11:24:51 PM (local time)

Just doesn't look right. I may need to use VBScript to do the conversion so I can put that in a macro. I found some samples and will continue working on them.

Thank you so much!
 
The Create date field is not encoded in Integer8. It is the actual date and time all appended together...

20030913175425.0Z = 2003-09-13 17:54:25 UTC
YYYYMMDDHHmmss

The lastLogonTimestamp returns the Integer8 date that can be converted with the w32tm command.

PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Good to see they export the data in a consistent format. Looks like I got what I need.

Thanks so much to all for your support.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top