我希望能够在Active Directory中查询User对象的所有可能的Active Directory属性(List of all AD User attributes)。
目前我正在为属性执行以下操作,例如:lastLogon
:
(principal是Principal
个对象)
DirectoryEntry directoryEntry = principal.GetUnderlyingObject() as DirectoryEntry;
if (directoryEntry.Properties.Contains("lastLogon"))
{
return directoryEntry.Properties["lastLogon"].Value.ToString();
}
但这会给我System.__ComObject
作为值,因为directoryEntry
为空。
我的问题是:如何从Principal对象获取lastLogon
(或所有其他User属性)属性?
答案 0 :(得分:0)
我使用了一个适用于lastLogon的扩展类:
http://www.codeproject.com/Articles/565593/How-to-get-the-REAL-lastlogon-datetime-from-Active