Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
Output Disabled User Accounts
Logged in as: Guest
arrSession:exec spGetSession 2,16,52714
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
Post a VBScript
>> Output Disabled User Accounts
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
Output Disabled User Accounts -
10/16/2007 3:20:43 AM
Mindmesh
Posts: 71
Score: 0
Joined: 11/23/2004
From:
Status:
offline
This outputs all disabled user accounts
Const strOutFile = "C:\Disabled_Users1.log" Dim adConnection Dim rsUsers Dim notRespondedLogPath Dim strCmd Dim allUsers Dim intAccountID Set objFSO = CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(strOutFile) Then objFSO.DeleteFile(strOutFile) End If 'set connection to active directory Set adConnection = CreateObject("ADODB.Connection") adConnection.Provider = "ADsDSOObject" adConnection.Open("Ads Provider") Set rsUsers = CreateObject("ADODB.Recordset") strFilter = "(&(objectCategory=user))" strCmd = "<LDAP://DC=Domain,DC=com>;" & strFilter &_ "; Name,userAccountControl;subtree" 'create recordset containing all active directory users set rsUsers = adConnection.Execute(strCmd) 'loop throught recordset, pull out only users who hadn't responded yet 'unless the user is disabled (userAccountControl = 514) rsUsers.MoveFirst while not rsUsers.EOF intAccountID = rsUsers.fields("userAccountControl") If intAccountID = 514 Or intAccountID = 66050 Or intAccountID = 66082 Then ' http://support.microsoft.com/kb/305144 Write_to_Log (rsUsers.Fields("Name")) WScript.Echo rsUsers.Fields("Name") End If rsUsers.MoveNext Wend rsUsers.Close adConnection.Close Sub Write_to_Log(strLogMessage) Dim StreamOut If objFSO.FileExists(strOutFile) Then Set StreamOut = objFSO.OpenTextFile(strOutFile,8) Else Set StreamOut = objFSO.CreateTextFile(strOutFile) End If StreamOut.WriteLine strLogMessage StreamOut.Close Set StreamOut = Nothing End Sub
Post #: 1
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
Post a VBScript
>> Output Disabled User Accounts
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI