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。