密碼到期到特定時間的時間表

密碼到期到特定時間的時間表

在 Windows Server 2003 或 2008 以及 Active Directory 中,是否有一種方法可以在策略中指定當使用者密碼當天過期時,使其在某個特定時間(例如凌晨 4:00)過期。

問題出現了,因為到期發生在工作日的中間,例如上午 9:00。然後,當使用者已經登入網路中的 Windows 並使用不同的應用程式時,這些應用程式將由於身份驗證而開始出現錯誤行為。他們必須登出並重新登錄,Windows 才會要求輸入新密碼。

因此,如果他們早上登入時會要求輸入新密碼,那麼他們就不必在工作日重新登出。

一位 AD 管理員說:「讓他們在開始這一天之前檢查他們的密碼是否會過期」..但實際上,是誰這麼做的?

而且我無法存取 AD 來檢查這些類型的策略。那麼,這可能嗎?

答案1

據我所知這是不可能的。

可能會出現多個提醒通知,說明目前密碼將在 N 天後過期,並提供更改密碼的選項。如果使用者選擇忽略此提醒,那麼他們不幸的是在自掘墳墓。

答案2

我們也有類似的問題。

我能想到的唯一方法是每天晚上運行腳本,該腳本將遍歷活動目錄並確定哪個帳戶將在第二天過期。如果是,請標記它以更改密碼。程式碼如下所示;我還沒有嘗試運行這個腳本,所以它可能需要一些調整:

Const SEC_IN_DAY = 86400 
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000 
Const ADS_SCOPE_SUBTREE = 1000

dim strname
dim strdist
dim dtmvalue

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.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
        objCommand.CommandText = "SELECT distinguishedName, profilepath, name from 'LDAP://dc=Example,dc=com' where objectCategory = 'User'"        


     Set objuserRecordSet = objCommand.Execute

objUSerRecordSet.MoveFirst

Do Until objuserRecordSet.EOF  

    strdist = objuserRecordSet.Fields("distinguishedName").Value
    strname = objuserRecordSet.Fields("name").Value

    Set objUserLDAP = GetObject _ 
    ("LDAP://" & strdist) 

    intCurrentValue = objUserLDAP.Get("userAccountControl") 

        dtmValue = objUserLDAP.PasswordLastChanged  

        If intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Then 
            x  =  "The password does not expire." 
        Else 
                Set objDomainNT = GetObject("WinNT://escc.gov.uk") 
                intMaxPwdAge = objDomainNT.Get("MaxPasswordAge") 
                    If intMaxPwdAge < 0 Then 
                        x  = "Password does not expire" 
                    Else
                        intMaxPwdAge=intMaxPwdAge/86400
                        strold = ((dtmValue + intMaxPwdAge)-now)

                        if strold < 2 and strold > 0 then
                            objUserLDAP.pwdLastSet = 0
                            objUserLDAP.SetInfo
                        end if
                    end if

        End If 

    dtmValue= ""

    objuserrecordset.movenext   

Loop

相關內容