获取Active Directory中当前登录用户的列表 [英] Get list of current logged in users in Active Directory

查看:95
本文介绍了获取Active Directory中当前登录用户的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从Active Directory域控制器获取当前登录用户的列表。

I'm trying to get list of current logged in users from Active Directory domain controller.

我可以通过使用以下代码来获取所有用户的列表但无法获取当前登录的用户列表。

I'm able to get list of all users by using following code but not able to get current logged in users list.

using (var context = new PrincipalContext(ContextType.Domain, "domain.net")) {
   using (var searcher = new PrincipalSearcher(new UserPrincipal(context))){
      List<UserPrincipal> users = searcher.FindAll().Select(u => (UserPrincipal)u).ToList();
      foreach (var u in users) {
           Resonse.Write(u.Name);
           Response.Write(u.LastLogon);
      }
   }
}

是否可以使用AD?如果我们可以通过其他任何方式实现目标,那么我也很开放。我只需要当前登录的AD域用户列表即可。

Is it possible using AD? If we can achieve with any alternate ways than also I'm open. I just need current logged in users list of AD domain users.

谢谢!

推荐答案

AD不支持。如果您进行审核,则可以从DC的事​​件日志中提取信息。我还看到人们使用登录脚本将值写入AD帐户的extensionAttributes。另一个选择是联系每台计算机,并为每台计算机查询当前登录的用户。

AD doesn't support it. You may be able to pull the info from the Event Logs on the DC's if you have auditing on. I've also seen people use a logon script to write a value into the extensionAttributes of the AD account. The other option is to reach out to each computer and query the currently logged on user for each of them.

这篇关于获取Active Directory中当前登录用户的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆