Re: Modify pwdLastSet by Bart
Bart
Tue Jul 20 15:02:05 CDT 2004
Mike,
Thank you !!
Mike Brierley wrote:
> Bart Reames wrote:
>
>> Hello all,
>>
>> Is it possiable to set the AD user attribure "pwdLastSet" to a
>> predetermined date (e.g. 127343762156911250 = 7/15/2004 10:43 AM)
>>
>> Thank you.
>>
> No you cant, but you CAN set it to todays date.
> run once this way
> objUser.Put "pwdLastSet", 0
> then
> objUser.Put "pwdLastSet", -1
>
>
> I use this script, courtesy of R. meuller.
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ' Program ExpirePassword.vbs.
> Option Explicit
>
> Dim strExcelPath, objExcel, objSheet, intRow, strUserDN
> Dim objUser
>
> ' Check for required arguments.
> If Wscript.Arguments.Count < 1 Then
> Wscript.Echo "Arguments <FileName> required. For example:" & vbCrLf _
> & "cscript ExpirePassword.vbs c:\UserList.xls"
> Wscript.Quit(0)
> End If
>
> ' Spreadsheet file.
> strExcelPath = Wscript.Arguments(0)
>
> ' Bind to Excel object.
> On Error Resume Next
> Set objExcel = CreateObject("Excel.Application")
> If Err.Number <> 0 Then
> On Error GoTo 0
> Wscript.Echo "Excel application not found."
> Wscript.Quit
> End If
> On Error GoTo 0
>
> ' Open spreadsheet.
> On Error Resume Next
> objExcel.Workbooks.Open strExcelPath
> If Err.Number <> 0 Then
> On Error GoTo 0
> Wscript.Echo "Spreadsheet cannot be opened: " & strExcelPath
> Wscript.Quit
> End If
> On Error GoTo 0
>
> ' Bind To worksheet.
> Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
>
> ' The first row of the spreadsheet is skipped (column headings). Each
> ' row after the first is processed until the first blank entry in the
> ' first column is encountered. The first column is the Distinguished
> ' Name of the user. intRow is the row number of the spreadheet.
> intRow = 2
> Do While objSheet.Cells(intRow, 1).Value <> ""
> strUserDN = objSheet.Cells(intRow, 1).Value
> On Error Resume Next
> Set objUser = GetObject("LDAP://" & strUserDN)
> If Err.Number <> 0 Then
> On Error GoTo 0
> Wscript.Echo "User NOT found: " & strUserDN
> WScript.Echo strUserDN
> Else
> WScript.Echo strUserDN
> objUser.Put "pwdLastSet", -1
> objUser.SetInfo
> If Err.Number <> 0 Then
> WScript.Echo Err.Number
> Wscript.Echo Err.Description
> On Error GoTo 0
> Wscript.Echo "Unable to expire password for user: " _
> & strUserDN
> End If
> On Error GoTo 0
> End If
> intRow = intRow + 1
> Loop
>
> ' Close the workbook.
> objExcel.ActiveWorkbook.Close
>
> ' Quit Excel.
> objExcel.Application.Quit
>
> ' Clean up.
> Set objUser = Nothing
> Set objExcel = Nothing
> Set objSheet = Nothing
>
> Wscript.Echo "Done"