AdvancedFilters.LastLogonTime(DateTime, MatchType) Metoda

Definicja

Ustawia filtr zapytania dla atrybutu LastLogon określony DateTime i określoną wartość porównania.

public:
 void LastLogonTime(DateTime logonTime, System::DirectoryServices::AccountManagement::MatchType match);
public void LastLogonTime (DateTime logonTime, System.DirectoryServices.AccountManagement.MatchType match);
member this.LastLogonTime : DateTime * System.DirectoryServices.AccountManagement.MatchType -> unit
Public Sub LastLogonTime (logonTime As DateTime, match As MatchType)

Parametry

logonTime
DateTime

Obiekt DateTime.

match
MatchType

Element MatchType określający sposób logonTime użycia w porównaniu.

Przykłady

// 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.LastLogonTime(DateTime.Now.AddDays(-1), MatchType.GreaterThan);  

// Create a PrincipalSearcher object.  
PrincipalSearcher ps = new PrincipalSearcher(usr);  
PrincipalSearchResult<Principal> results = ps.FindAll();  

//Write the names of all users who have logged on since yesterday  
foreach (UserPrincipal u in results)  
{  
	Console.WriteLine(u.Name);  
}  

Uwagi

Godzina domyślna to UTC. Jeśli chcesz określić godzinę w czasie lokalnym, określ Kind właściwość DateTime obiektu jako DateTimeKind.Local.

Dotyczy

Zobacz też