AdvancedFilters.LastLogonTime(DateTime, MatchType) Método

Definição

Define o filtro de consulta para o atributo LastLogon para o DateTime especificado e o valor de comparação especificado.Sets the query filter for the LastLogon attribute to the specified DateTime and the specified comparison value.

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)

Parâmetros

logonTime
DateTime

Um objeto DateTime.A DateTime object.

match
MatchType

Um MatchType que especifica como logonTime deve ser usado na comparação.A MatchType that specifies how logonTime should be used in the comparison.

Exemplos

// 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);  
}  

Comentários

O horário padrão será o UTC.The time will default to UTC. Se você quiser especificar a hora na hora local, especifique a Kind Propriedade do seu DateTime objeto como DateTimeKind.Local .If you want to specify the time in local time, then specify the Kind property of your DateTime object as DateTimeKind.Local.

Aplica-se a

Confira também