如何查看网络中的用户列表? [英] how to view list of user in network?

查看:88
本文介绍了如何查看网络中的用户列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过编程c#

推荐答案

Plz在网络中查看用户列表,请参见CodeProject:
Plz refer CodeProject at: Retreiving a list of network computer names using C#[^]


if (!String.IsNullOrEmpty(domainName))
   {
      DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}", domainName));
    DirectorySearcher mySearcher = new DirectorySearcher(myDirectoryEntry);
    SortOption mySort = new SortOption("sn", SortDirection.Ascending);
    mySearcher.Filter = ("(objectCategory=person)");
    mySearcher.Sort = mySort;
      foreach (SearchResult resEnt in mySearcher.FindAll())
        {
         
          if ( System.Text.RegularExpressions.Regex.IsMatch(resEnt.Properties["displayName"][0].ToString(), "         |admin|test|service|system|


", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { int space = resEnt.Properties["displayName"][0].ToString().IndexOf(" "); string formattedName = String.Format("{0}", resEnt.Properties["displayName"][0].ToString().Substring(space).PadRight(25), ); userList.Add(formattedName); } } }
", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) { int space = resEnt.Properties["displayName"][0].ToString().IndexOf(" "); string formattedName = String.Format("{0}", resEnt.Properties["displayName"][0].ToString().Substring(space).PadRight(25), ); userList.Add(formattedName); } } }


这篇关于如何查看网络中的用户列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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