|
|||||||||||
|
RE: How to generate a report of inactive domain user accounts
From: Tiago Halm <thalm(at)netcabo.pt>
Date: Fri Apr 11 2003 - 19:11:51 EDT
Here goes,
Sub RecurseLDAP(ByVal p_sAdsPath, ByVal p_sDCName) Dim oOBJ, oSHM, oCHD, oValue Set oOBJ = GetObject(p_sAdsPath) Set oSHM = GetObject(oOBJ.Schema) Call oOBJ.GetInfo On Error Resume Next oValue = oOBJ.LastLogin If Err.Number = 0 Then Dim dCurrDate, dOldDate dCurrDate = DateValue(oValue) dCurrDate = CDate(Year(dCurrDate) & "-" & Month(dCurrDate) & End Sub Sub FormatDict(ByVal p_sFile)
Dim oFSO, oTS, dDate
Dim arrKeys, nIndex, sYear
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.CreateTextFile(p_sFile, True, True)
Call oTS.WriteLine("Class" & vbTab & "Acount" & vbTab & "cn" & vbTab
& "Date/Time")
arrKeys = oDict.Keys
For nIndex = 0 To oDict.Count - 1
dDate = DateValue(oDict.Item(arrKeys(nIndex))(2))
sYear = Year(dDate)
If CLng(sYear) < 1970 Then sYear = "1970"
Call oTS.WriteLine(oDict.Item(arrKeys(nIndex))(0) & vbTab &
arrKeys(nIndex) & vbTab & oDict.Item(arrKeys(nIndex))(1) & vbTab & sYear &
"-" & Month(dDate) & "-" & Day(dDate) & " " & TimeValue(oDict.Item(arrKeys(nIndex))(2))) Next
Call oTS.Close
If WScript.Arguments.Count < 3 Then WScript.Echo "Usage: ChechLogin.vbs End If Dim dtNow, oDict, sFile, sSite, nDCIndex, sDCName
dtNow = Now
For nDCIndex = 2 To WScript.Arguments.Count - 1
sDCName = WScript.Arguments(nDCIndex)
Call RecurseLDAP("LDAP://" & sDCName & "/" & sSite, sDCName)
Next
Call FormatDict(sFile) ------------------ end -----------------------
Hope it helps,
Block Spam, Smut & Viruses SurfControl E-mail Filter for SMTP & Exchange leverages multiple layers of technology including filtering embedded and attached file content. Rid your enterprise of unwanted content. http://www.securityfocus.com/SurfControl-focus-ms2 Download your free fully functional trial, complete with 30-days of free technical support. Received on Sat Apr 12 02:36:46 2003 This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 14:01:29 EDT |
||||||||||
|
|||||||||||