Запрос в AD
Модератор: Модераторы
Сообщений: 4
• Страница 1 из 1
Можно попробывать сделать на основе вот такого скрипта
Код |
Const SEC_IN_DAY = 86400
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 Set objUserLDAP = GetObject _ ("LDAP://CN=myerken,OU=management,DC=fabrikam,DC=com") intCurrentValue = objUserLDAP.Get("userAccountControl") If intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Then Wscript.Echo "The password does not expire." Else dtmValue = objUserLDAP.PasswordLastChanged Wscript.Echo "The password was last changed on " & _ DateValue(dtmValue) & " at " & TimeValue(dtmValue) & VbCrLf & _ "The difference between when the password was last set" & _ "and today is " & int(now - dtmValue) & " days" intTimeInterval = int(now - dtmValue) Set objDomainNT = GetObject("WinNT://fabrikam") intMaxPwdAge = objDomainNT.Get("MaxPasswordAge") If intMaxPwdAge < 0 Then WScript.Echo "The Maximum Password Age is set to 0 in the " & _ "domain. Therefore, the password does not expire." Else intMaxPwdAge = (intMaxPwdAge/SEC_IN_DAY) Wscript.Echo "The maximum password age is " & intMaxPwdAge & " days" If intTimeInterval >= intMaxPwdAge Then Wscript.Echo "The password has expired." Else Wscript.Echo "The password will expire on " & _ DateValue(dtmValue + intMaxPwdAge) & " (" & _ int((dtmValue + intMaxPwdAge) - now) & " days from today" & _ ")." End If End If End If [/code] Правильно заданный вопрос - это уже половина ответа.
' List of "passwd never expires" users
ADOMAIN = "dc=rrr,dc=local" Set fso = CreateObject("Scripting.FileSystemObject") Set outfile = fso.CreateTextFile("outfile.txt", True) Const ADS_UF_ACCOUNTDISABLE = 2 Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=ADsDSOObject;" Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText = _ "<GC://" & ADOMAIN & ">;(objectCategory=User)" & _ ";userAccountControl,distinguishedName;subtree" Set objRecordSet = objCommand.Execute intCounter = 0 Do Until objRecordset.EOF intUAC=objRecordset.Fields("userAccountControl") If intUAC AND ADS_UF_DONT_EXPIRE_PASSWD Then If intUAC AND ADS_UF_ACCOUNTDISABLE Then STAT= " - disabled" Else STAT= "" End If outfile.WriteLine objRecordset.Fields("distinguishedName") & STAT intCounter = intCounter + 1 End If objRecordset.MoveNext Loop WScript.Echo VbCrLf & "A total of " & intCounter & " accounts found." objConnection.Close outfile.Close
Сообщений: 4
• Страница 1 из 1
Вернуться в Автоматизация процесса управления Кто сейчас на конференцииСейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 7 |