次の方法で共有


AdvancedFilters.LastPasswordSetTime(DateTime, MatchType) メソッド

定義

LastPasswordSet 属性のクエリ フィルターを、指定された DateTime と指定された比較値に設定します。

public:
 void LastPasswordSetTime(DateTime passwordSetTime, System::DirectoryServices::AccountManagement::MatchType match);
public void LastPasswordSetTime (DateTime passwordSetTime, System.DirectoryServices.AccountManagement.MatchType match);
member this.LastPasswordSetTime : DateTime * System.DirectoryServices.AccountManagement.MatchType -> unit
Public Sub LastPasswordSetTime (passwordSetTime As DateTime, match As MatchType)

パラメーター

passwordSetTime
DateTime

DateTime オブジェクト。

match
MatchType

passwordSetTime を比較に使用する方法を指定する MatchType

// Create the principal context for the usr object.  
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "fabrikam.com", "CN=Users,DC=fabrikam,DC=com", "administrator", "SecurelyStoredPassword");  

// Create the principal user object from the context  
UserPrincipal usr = new UserPrincipal(ctx);  

// Set the advanced query filter  
usr.AdvancedSearchFilter.LastPasswordSetTime(DateTime.Now.AddDays(-30), MatchType.LessThan);  

// Create a PrincipalSearcher object.  
PrincipalSearcher ps = new PrincipalSearcher(usr);  
PrincipalSearchResult<Principal> results = ps.FindAll();  

//Force users who have not changed their password in the last  
//30 days to do so at next logon  
foreach (UserPrincipal u in results)  
{  
	u.ExpirePasswordNow();  
	u.Save();  
}  

注釈

時刻は既定で UTC になります。 現地時刻で時刻を指定する場合は、オブジェクトの プロパティを KindDateTime として DateTimeKind.Local指定します。

適用対象

こちらもご覧ください