捐血一袋救人一命

2012年1月6日 星期五

找出網域中密碼從未過期的帳號

功能:檢核系統設定,確保每個帳號均遵循密碼定時重設的政策

image

請將檔案存成 .vbs

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.CommandText = "<LDAP://dc=company,dc=com,dc=tw>;" & "(&(objectCategory=User)(userAccountControl:1.2.840.113556.1.4.803:=65536));" & "Name;Subtree"
Set objRecordSet = objCommand.Execute

NeverExpirePassword = "密碼從未過期的帳號清單:" + CHR(13) + CHR(13)

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    NeverExpirePassword = NeverExpirePassword + objRecordSet.Fields("Name").Value + CHR(13)
    objRecordSet.MoveNext
Loop

Wscript.Echo NeverExpirePassword

0 意見: