Login | |
|
 |
Re: Writing to a text file. Permission Denied-Solved - 6/28/2005 3:52:49 AM
|
|
 |
|
| |
D4y
Posts: 27
Score: 0
Joined: 4/1/2005
From:
Status: offline
|
ok I have changed it some but now i get Permission Denied on Line 50 which is Set objTS = objFSO.OpenTextFile("C:\" & strLdapPath & ".txt", ForWriting, True) here is the modified code: Option Explicit Dim strLdapPath Dim objConnection Dim objChild Dim lngTZBias Dim objUser Dim objPwdLastSet Dim objShell Dim lngBiasKey Dim k Dim Input Dim objFSO Dim objTextFile Dim objTS '============================================================================================= 'Input box for computername Input = InputBox("Enter Ldap Path","Get Last Password Set Time") strLdapPath = Input If strLdapPath = "" Then WScript.Quit End If '============================================================================================= ' Obtain local Time Zone bias from machine registry. Set objShell = CreateObject("Wscript.Shell") lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\"_ & "TimeZoneInformation\ActiveTimeBias") If UCase(TypeName(lngBiasKey)) = "LONG" Then lngTZBias = lngBiasKey ElseIf UCase(TypeName(lngBiasKey)) = "VARIANT()" Then lngTZBias = 0 For k = 0 To UBound(lngBiasKey) lngTZBias = lngTZBias + (lngBiasKey(k) * 256^k) Next End If '============================================================================================= 'Connect to LDAP Set objConnection = GetObject("LDAP://" & strLdapPath) objConnection.Filter = Array("user") Const ForWriting = 2 For Each objChild In objConnection Set objPwdLastSet = objChild.pwdLastSet '============================================================================================= 'Write to Text File Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTS = objFSO.OpenTextFile("C:\" & strLdapPath & ".txt", ForWriting, True) Next Function Integer8Date(objDate, lngBias) '============================================================================================= ' Function to convert Integer8 (64-bit) value to a date, adjusted for local time zone bias. Dim lngAdjust, lngDate, lngHigh, lngLow lngAdjust = lngBias lngHigh = objDate.HighPart lngLow = objdate.LowPart '============================================================================================= ' Account for error in IADslargeInteger property methods. If lngLow < 0 Then lngHigh = lngHigh + 1 End If If (lngHigh = 0) And (lngLow = 0) Then lngAdjust = 0 End If lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _ + lngLow) / 600000000 - lngAdjust) / 1440 '============================================================================================= ' Trap error if lngDate is ridiculously huge. On Error Resume Next Integer8Date = CDate(lngDate) If Err.Number <> 0 Then On Error GoTo 0 Integer8Date = #1/1/1601# End If On Error GoTo 0 End Function For Each objChild In objConnection objTS.WriteLine objChild.Name & vbTab & _ Integer8Date(objPwdLastSet, lngTZBias) Next objTS.Close
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|