AdvancedFilters.LastBadPasswordAttempt(DateTime, MatchType) 方法

定義

LastBadPasswordAttempt 屬性的查詢篩選條件設定為指定的 DateTime 和指定的比較值。

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

參數

lastAttempt
DateTime

DateTime 物件。

match
MatchType

MatchType,指定應該如何在比較中使用 lastAttempt

範例

// 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.LastBadPasswordAttempt(DateTime.Now.AddDays(-1), MatchType.GreaterThan);  

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

//Write the name of all users whose most recent incorrect  
//password entry was within the last day  

foreach (UserPrincipal u in results)  
{  
	Console.WriteLine(u.Name);  
}  

備註

時間預設為UTC。 如果您要以當地時間指定時間,請將 物件的 屬性DateTime指定KindDateTimeKind.Local

適用於

另請參閱