AdvancedFilters.LastLogonTime(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.
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)
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.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);
}
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
Colaborați cu noi pe GitHub
Sursa pentru acest conținut poate fi găsită pe GitHub, unde puteți, de asemenea, să creați și să consultați probleme și solicitări de tragere. Pentru mai multe informații, consultați ghidul nostru pentru colaboratori.