2011-12-23 13 views
1

PSOポリシーが設定した最大日数を取得するためのvbscriptの作成方法を調べる。それは価値として戻ってくる...そして、私はどのように設定された本当の価値を得るか分からない。Active Directory PSO細かいパスワードmsDS-MaximumPasswordAge

これは私がこれまで持っているものです。

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 

私はCNの値とさえmsDS-PasswordSettingsPrecedenceではなくmsDS-MaximumPasswordAgeのために取得することができます。どんな助けもありがとう。

答えて

0

これは、せいぜい部分的な答えですが、私はいくつかの検索を行なったし、私はあなたが次の一つ以上必要と考えている:PSOのを管理するために

  1. DSGet/DSQUERY
  2. LDIFDEを。
  3. クエストのクエストの無料ツールを使用する「Free PowerShell Commands for Active Directory

、あなたが私たちのActive Directoryの周りにこのlink便利

0

あなたは、現在のパスワードの最大年齢でLDAP属性を取得し、最後にLDAPクエリ

ldapFilterString = "(&(objectClass=msDS-PasswordSettings))"; 

を実行することを

domainLookupString = ""CN=UsersPSO,CN=Password Settings Container,CN=System,DC=COMPAY,DC=ORG"; 

ようなあなたのADにUsersPSOの場所を見つけなければなりませんPSOポリシー

"msDS-MaximumPasswordAge" 
関連する問題