《2022年域账户状态查询工具 .pdf》由会员分享,可在线阅读,更多相关《2022年域账户状态查询工具 .pdf(5页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、 AD密码状态检查 H1 font-family:Tahoma; font-weight:bold; font-size:18pt; color:black; text-align:left; margin-top:2pt; margin-bottom:10pt; H2 font-family:Tahoma; font-weight:bold; font-size:10pt; color:maroon; text-align:left; margin-top:2pt; margin-bottom:2pt; body font-family:Verdana; font-weight:normal
2、; font-size:8.5pt; background-color:#99CCFF; margin-left:10pt; margin-rigth:2pt; margin-top:7pt; .hd font-weight:bold; font-size:8pt; text-align:left; vertical-align:middle; background-color:#DDD; .hd2 font-weight:bold; font-size:8pt; text-align:left; vertical-align:middle; color:gray; .col font-siz
3、e:8pt; text-align:left; vertical-align:top; background-color:#EEE; .col2 font-size:8pt; text-align:left; vertical-align:top; Const strAbout = 3.0 (2007 年 8 月 8 日) Const strCopyr = 信息管理部 Const strHelp = 在域控上以管理员身份运行本脚本,在文本框中输入正确的域名后缀再点击按钮。 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心
4、整理 - - - - - - - 第 1 页,共 5 页 - - - - - - - - - Window.resizeTo 400, 230 Sub RunScript On Error Resume Next Const ADS_SCOPE_SUBTREE = 2 Const SEC_IN_DAY = 86400 Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 Const ForWriting = 2 Const E_ADS_Property_Not_Found = &h8000500D Const E_Table_Not_Found = &h80040
5、E37 If BasicTextBox.value= Then InfoArea.InnerHTML=请在文本框中输入本域的域名后缀,再点击按钮! Exit Sub Else document.body.style.cursor = wait InfoArea.InnerHTML=正在运行 ,请稍候 . DomainName=BasicTextBox.value intDotPlace=Instr(1,DomainName,.,1) If intDotPlace=0 Then LDAPDomain=LDAP:/DC= +DomainName BiosDomain=DomainName Else
6、 LDAPDomain=LDAP:/DC= +Replace(DomainName, ., ,DC=) BiosDomain=Left(DomainName,intDotPlace-1) End If End If Set fso = CreateObject(Scripting.FileSystemObject) Set objConnection = CreateObject(ADODB.Connection) Set objCommand = CreateObject(ADODB.Command) objConnection.Provider = ADsDSOObject objConn
7、ection.Open Active Directory Provider Set objCommand.ActiveConnection = objConnection objCommand.CommandText = _ Select distinguishedName from & LDAPDomain & _ where objectClass =user and objectClass computer objCommand.Properties(Page Size) = 10000 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - -
8、 - - - 名师精心整理 - - - - - - - 第 2 页,共 5 页 - - - - - - - - - objCommand.Properties(Searchscope) = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute IF err.number = E_Table_Not_Found Then InfoArea.InnerHTML=域名输入错误,请重新输入! document.body.style.cursor = default Exit Sub End If objRecordSet.MoveFirst 设
9、置输出结果,用户可以自行修改文件名称和路径OutFile = passstate.csv Set txtStreamOut = fso.OpenTextFile(OutFile,ForWriting,true) 结果集的表头信息txtStreamOut.WriteLine 帐户名称 ,账户状态 ,上次修改时间,上次修改时间距今几天,下一次修改时间,密码有效时间 Do Until objRecordSet.EOF LDAPUser=LDAP:/ +objRecordSet.Fields(distinguishedName).Value 获得用户帐号信息Set objUserLDAP = GetO
10、bject(LDAPUser) intCurrentValue = objUserLDAP.Get(userAccountControl) 根据控制位最后两位判断,如果最后两位是二进制10,说明账户被禁用If (intCurrentValue and 3)=2 Then AccountControl = 账户被禁用 Else AccountControl = 账户已启用 End If 判断用户密码是否设置为永不过期If intCurrentValue And ADS_UF_DONT_EXPIRE_PASSWD Then OutText=objUserLDAP.Get(sAMAccountNam
11、e) & , & AccountControl &, 密码永不过期, txtStreamOut.WriteLine OutText Else 如果用户密码没有设置为永不过期,获得最后一次修改密码的时间,并计算最后一次修改密码距今的时间dtmValue = objUserLDAP.Passwordlastchanged If err.number = E_ADS_Property_Not_Found Then intTimeInterval = -1 Else intTimeInterval = int(now - dtmValue) End If Err.number = 0 名师资料总结 -
12、 - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 5 页 - - - - - - - - - 获得密码最长时间Set objDomainNT = GetObject(WinNT:/ & BiosDomain) intMaxPwdAge = objDomainNT.Get(MaxPasswordAge) 如果密码最长时间没有设置,提示用户并退出脚本运行If intMaxPwdAge = intMaxPwdAge Then OutText=objUserLDAP.Get(sAMAccountN
13、ame) & , & AccountControl & , & DateValue(dtmValue) & & _ TimeValue(dtmValue) & , & int(now - dtmValue) & ,密码过期!, txtStreamOut.WriteLine OutText Else If intTimeInterval = -1 Then OutText=objUserLDAP.Get(sAMAccountName) & , & AccountControl & ,下次登陆修改密码, txtStreamOut.WriteLine OutText Else 否则,显示密码有效时间
14、OutText=objUserLDAP.Get(sAMAccountName) & , & AccountControl & , & DateValue(dtmValue) & & _ TimeValue(dtmValue) & , & int(now - dtmValue) & , & _ DateValue(dtmValue + intMaxPwdAge) & , & int(dtmValue + intMaxPwdAge) - now) txtStreamOut.WriteLine OutText End If End If End If End If objRecordSet.Move
15、Next Loop InfoArea.InnerHTML= 请打开 & OutFile & 检查帐号密码状态. 按 F5 重新运行! 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 5 页 - - - - - - - - - document.body.style.cursor = default End Sub Sub setx(t) Dim obj : Set obj = window.event.srcElement If t = Then obj.style.co
16、lor = gray obj.style.cursor = default Else obj.style.color = darkblue obj.style.cursor = hand End If footer.innerHTML = t End Sub AD 账户密码状态检查 在下面的文本框中输入本地域名后缀,其格式类似于:ABC.COM 然后点击开始按钮: 信息 :无 版本 | 作者 | 帮助 | 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 5 页 - - - - - - - - -