AdvancedFilters.BadLogonCount(Int32, MatchType) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 BadLogonCount 屬性的查詢篩選條件設定為指定的值和比較類型。
public:
void BadLogonCount(int badLogonCount, System::DirectoryServices::AccountManagement::MatchType match);
public void BadLogonCount (int badLogonCount, System.DirectoryServices.AccountManagement.MatchType match);
member this.BadLogonCount : int * System.DirectoryServices.AccountManagement.MatchType -> unit
Public Sub BadLogonCount (badLogonCount As Integer, match As MatchType)
參數
- badLogonCount
- Int32
整數。
範例
// 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
int badLogonThreshold = 3;
usr.AdvancedSearchFilter.BadLogonCount(badLogonThreshold, MatchType.GreaterThan);
// Create a PrincipalSearcher object.
PrincipalSearcher ps = new PrincipalSearcher(usr);
PrincipalSearchResult<Principal> results = ps.FindAll();
Console.WriteLine("The following users have logged on unsuccessfully at more than " + badLogonThreshold.toString + " times:");
foreach (UserPrincipal u in results)
{
Console.WriteLine(u.Name);
}