AdvancedFilters.AccountExpirationDate(DateTime, MatchType) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the query filter for the AccountExpirationDate attribute to the specified time and comparison type.
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)
Parameters
Examples
// 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);
}
Remarks
The time will default to UTC. If you want to specify the time in local time, then specify the Kind property of your DateTime object as DateTimeKind.Local.
Applies to
See also
Col·laboreu amb nosaltres a GitHub
La font d'aquest contingut es pot trobar al GitHub, on també podeu crear i revisar problemes i sol·licituds d'extracció. Per obtenir més informació, consulteu la nostra guia per a col·laboradors.