Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
Output AD Users with Password set to Not Expire
Logged in as: Guest
arrSession:exec spGetSession 2,16,52713
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
Post a VBScript
>> Output AD Users with Password set to Not Expire
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 AD Users with Password set to Not Expire -
10/16/2007 3:18:54 AM
Mindmesh
Posts: 71
Score: 0
Joined: 11/23/2004
From:
Status:
offline
This should print to a text files AD accounts with the "Password Never Expires" flag set.
Const strOutFile = "C:\Password_Never_Expires.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 = 66048) rsUsers.MoveFirst While not rsUsers.EOF intAccountID = rsUsers.fields("userAccountControl") If intAccountID = 66048 Then ' http://support.microsoft.com/kb/305144 66048 = 512 ( Normal User) + 66536(Password_Don't_expire) 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 AD Users with Password set to Not Expire
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