Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForReading = 1
Const intForAppending = 8
strDisableAccountsFile = "\\serverxx\tracking\UsersToDisable.txt"
strDisabledReportFile = "\\serverxx\tracking\DisabledUsers.txt"
Set objOutput = objFSO.OpenTextFile(strDisabledReportFile, intForAppending, True)
Set objFile = objFSO.OpenTextFile(strDisableAccountsFile, intForReading, True)
While Not objFile.AtEndOfStream
strUserDN = objFile.ReadLine
If Trim(strUserDN) <> "" Then
Set objUser = GetObject("LDAP://" & strUserDN)
objUser.AccountDisabled = True
objUser.SetInfo
Set objUser = Nothing
objOutput.WriteLine strUserDN
End If
Wend
objFile.Close
objOutput.Close
Set objFile = Nothing
Set objOutput = Nothing
Set objFile = objFSO.CreateTextFile(strDisableAccountsFile, True)
objFile.Close
Set objFile = Nothing
MsgBox "Accounts that have been disabled have been written to " & VbCrLf & strDisabledReportsFile & VbCrLf & "and the file of users to disalbe has been cleared " & strDisableAccountsFile
|