Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Password Properties

Status
Not open for further replies.

namkiwi

IS-IT--Management
Sep 26, 2001
23
NZ
Does anyone have a script that can write the properties, specifically "Password never expires" into a log file. I have written a script which runs without errors but does not put anything in the log file

Set objHash = CreateObject("Scripting.Dictionary")

objHash.Add "ADS_UF_DONT_EXPIRE_PASSWD", &h10000

Set objDictionary = CreateObject("Scripting.Dictionary")
i=0
Set objOU = GetObject("LDAP://OU=Accounting Users, OU=Accounting OU, OU=Corporate Services OU, DC=xxx, DC=xxx,

DC=xx")
objOU.Filter = Array("User")
On Error Resume Next
For Each objUser in objOU
objDictionary.Add i, objUser.CN
i=i+1
Next
intUAC = objUser.Get("userAccountControl")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Password Check.txt", ForAppending)

For Each Key In objHash.Keys
If objHash(Key) And intUAC Then
Wscript.Echo Key & " is enabled"
Else
objFile.WriteLine "User " Key & "disabled"
objFile.Close

End If
Next

Thanks

Frank Aldridge
IT Professional
New Zealand
 
You have some issue with your For .. Next loops.
Here a skeleton of nested loops:
Code:
Set objHash = CreateObject("Scripting.Dictionary")
objHash.Add "ADS_UF_DONT_EXPIRE_PASSWD", &h10000
Set objOU = GetObject("LDAP://OU=Accounting Users, OU=Accounting OU, OU=Corporate Services OU, DC=xxx, DC=xxx, 
DC=xx")
objOU.Filter = Array("User")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Password Check.txt", ForAppending)
On Error Resume Next
For Each objUser in objOU
  intUAC = objUser.Get("userAccountControl")
  For Each Key In objHash.Keys   ' ???
    If objHash(Key) And intUAC Then 
      Wscript.Echo Key & " is enabled for " & objUser.CN
    Else
      objFile.WriteLine "User " & Key & " disabled"
    End If
  Next
Next
objFile.Close

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top