次の方法で共有


AdvancedFilters.LastLogonTime(DateTime, MatchType) メソッド

定義

LastLogon 属性のクエリ フィルターを、指定された DateTime と指定された比較値に設定します。

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)

パラメーター

logonTime
DateTime

DateTime オブジェクト。

match
MatchType

logonTime を比較に使用する方法を指定する 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.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);  
}  

注釈

時刻の既定値は UTC です。 現地時刻で時刻を指定する場合は、オブジェクトの プロパティを KindDateTime として DateTimeKind.Local指定します。

適用対象

こちらもご覧ください