Vbscript Active Directory PSO细粒度密码msDS MaximumPasswordAge

Vbscript Active Directory PSO细粒度密码msDS MaximumPasswordAge,vbscript,Vbscript,查看如何创建vbscript以获取PSO策略设置的最大天数。它以…的值返回。。。我不知道如何得到设定的实际值 这就是我到目前为止所做的: Option Explicit Const ADS_UF_PASSWD_CANT_CHANGE = &H40 Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000 Dim strFilePath, objFSO, objFile, adoConnection, adoCommand, objCDOConf Di

查看如何创建vbscript以获取PSO策略设置的最大天数。它以…的值返回。。。我不知道如何得到设定的实际值

这就是我到目前为止所做的:

Option Explicit

Const ADS_UF_PASSWD_CANT_CHANGE = &H40
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000

Dim strFilePath, objFSO, objFile, adoConnection, adoCommand, objCDOConf
Dim objRootDSE, strDNSDomain, strFilter, strQuery, adoRecordset, objMaxPwdAge
Dim strDN, objShell, lngBiasKey, lngBias, blnPwdExpire, strDept, strAdd
Dim objDate, dtmPwdLastSet, lngFlag, k, address, objAdd, objMessage

' Check for required arguments.
If (Wscript.Arguments.Count < 1) Then
    Wscript.Echo "Arguments <FileName> required. For example:" & vbCrLf _
        & "cscript PwdLastChanged.vbs c:\MyFolder\UserList.txt"
    Wscript.Quit(0)
End If

strFilePath = Wscript.Arguments(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Open the file for write access.
On Error Resume Next
Set objFile = objFSO.OpenTextFile(strFilePath, 2, True, 0)
If (Err.Number <> 0) Then
    On Error GoTo 0
    Wscript.Echo "File " & strFilePath & " cannot be opened"
    Wscript.Quit(1)
End If
On Error GoTo 0

Set objShell = CreateObject("Wscript.Shell")
lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\" _
    & "TimeZoneInformation\ActiveTimeBias")
If (UCase(TypeName(lngBiasKey)) = "LONG") Then
    lngBias = lngBiasKey
ElseIf (UCase(TypeName(lngBiasKey)) = "VARIANT()") Then
    lngBias = 0
    For k = 0 To UBound(lngBiasKey)
        lngBias = lngBias + (lngBiasKey(k) * 256^k)
    Next
End If

' Use ADO to search the domain for all users.
Set adoConnection = CreateObject("ADODB.Connection")
Set adoCommand = CreateObject("ADODB.Command")
adoConnection.Provider = "ADsDSOOBject"
adoConnection.Open "Active Directory Provider"
Set adoCommand.ActiveConnection = adoConnection

' Determine the DNS domain from the RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")

' Filter to retrieve all user objects.
strFilter = "(&(objectClass=msDS-PasswordSettings))"

' Filter to retrieve all computer objects.    
strQuery = "<LDAP://CN=PSO-Information Systems,CN=Password Settings Container,CN=System,DC=yrmc,DC=org>;" _
    & ";cn,msDS-LockoutDuration,msDS-MaximumPasswordAge,msDS-

PasswordSettingsPrecedence;subtree"

    adoCommand.CommandText = strQuery
    adoCommand.Properties("Page Size") = 100
    adoCommand.Properties("Timeout") = 30
    adoCommand.Properties("Cache Results") = False

Set adoRecordset = adoCommand.Execute
Do Until adoRecordset.EOF
    objFile.WriteLine adoRecordset.Fields("cn").Value
    adoRecordset.MoveNext
Loop
adoRecordset.Close
选项显式
Const ADS_UF_PASSWD_CANT_CHANGE=&H40
Const ADS_UF_not_EXPIRE_PASSWD=&H10000
Dim strFilePath、objFSO、objFile、adoConnection、adoCommand、objCDOConf
Dim objRootDSE、strndsDomain、strFilter、strQuery、adoRecordset、objMaxPwdAge
Dim strDN、objShell、lngBiasKey、lngBias、BLNPWDEXIRE、strDept、strAdd
Dim objDate、dtmPwdLastSet、lngFlag、k、地址、objAdd、objMessage
'检查所需的参数。
如果(Wscript.Arguments.Count<1),则
需要Wscript.Echo“参数。例如:”&vbCrLf_
&“cscript PwdLastChanged.vbs c:\MyFolder\UserList.txt”
Wscript.Quit(0)
如果结束
strFilePath=Wscript.Arguments(0)
设置objFSO=CreateObject(“Scripting.FileSystemObject”)
'打开文件以进行写访问。
出错时继续下一步
设置objFile=objFSO.OpenTextFile(strFilePath,2,True,0)
如果(错误编号0),则
错误转到0
Wscript.Echo“文件”&strFilePath&“无法打开”
Wscript.Quit(1)
如果结束
错误转到0
设置objShell=CreateObject(“Wscript.Shell”)
lngBiasKey=objShell.regrad(“HKLM\System\CurrentControlSet\Control\”_
&“时区信息\ActiveTimeBias”)
如果(UCase(TypeName(lngBiasKey))=“LONG”),则
lngBias=lngBiasKey
ElseIf(UCase(TypeName(lngBiasKey))=“VARIANT()”)然后
lngBias=0
对于k=0到UBound(lngBiasKey)
lngBias=lngBias+(lngBiasKey(k)*256^k)
下一个
如果结束
'使用ADO搜索域中的所有用户。
设置adoConnection=CreateObject(“ADODB.Connection”)
Set adoCommand=CreateObject(“ADODB.Command”)
adoConnection.Provider=“ADsDSOOBject”
adoConnection。打开“Active Directory提供程序”
设置adoCommand.ActiveConnection=adoConnection
'从RootDSE对象确定DNS域。
设置objRootDSE=GetObject(“LDAP://RootDSE”)
strndsdomain=objRootDSE.Get(“DefaultNamingContext”)
'筛选以检索所有用户对象。
strFilter=“(&(objectClass=msDS PasswordSettings))”
'筛选以检索所有计算机对象。
strQuery=“;”_
&“cn、msDS锁定持续时间、msDS MaximumPasswordAge、msDS-
PasswordSettingsRecessence;子树“
adoCommand.CommandText=strQuery
adoCommand.Properties(“页面大小”)=100
adoCommand.Properties(“超时”)=30
adoCommand.Properties(“缓存结果”)=False
Set adoRecordset=adoCommand.Execute
直到adoRecordset.EOF为止
objFile.WriteLine adoRecordset.Fields(“cn”).Value
adoRecordset.MoveNext
环
adoRecordset,关闭

我可以为cn甚至
msDS PasswordSettingsRecessence
获取值,但不能为
msDS MaximumPasswordAge
获取值。任何帮助都将不胜感激。

这充其量只是部分回答,但我做了一些搜索,我相信您将需要以下一项或多项:

  • /数据查询
  • 管理PSO
  • 任务的“

  • 使用Quest的免费工具,您可能会发现这很方便

    用方括号括住Active Directory属性名称:


    有关更多信息,请参阅博文。

    您必须在您的广告中找到UsersPSO位置

    domainLookupString = ""CN=UsersPSO,CN=Password Settings Container,CN=System,DC=COMPAY,DC=ORG";
    
    然后运行ldap查询

    ldapFilterString = "(&(objectClass=msDS-PasswordSettings))";
    
    最后,获取具有当前PSO策略的最大密码期限的ldap属性

    "msDS-MaximumPasswordAge"