AdvancedFilters.AccountExpirationDate(DateTime, MatchType) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 AccountExpirationDate 屬性的查詢篩選條件設定為指定的時間和比較類型。
public:
void AccountExpirationDate(DateTime expirationTime, System::DirectoryServices::AccountManagement::MatchType match);
public void AccountExpirationDate (DateTime expirationTime, System.DirectoryServices.AccountManagement.MatchType match);
member this.AccountExpirationDate : DateTime * System.DirectoryServices.AccountManagement.MatchType -> unit
Public Sub AccountExpirationDate (expirationTime As DateTime, match As 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.AccountExpirationDate(DateTime.Now, MatchType.LessThan);
// Create a PrincipalSearcher object.
PrincipalSearcher ps = new PrincipalSearcher(usr);
PrincipalSearchResult<Principal> results = ps.FindAll();
Console.WriteLine("The following users' accounts have expired:");
foreach (UserPrincipal u in results)
{
Console.WriteLine(u.Name);
}
備註
時間預設為UTC。 如果您要以當地時間指定時間,請將物件的 DateTime 屬性指定Kind為 DateTimeKind.Local。