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

适用于

另请参阅