在Active Directory中的在线计算机列表 [英] List of computers in Active Directory that are online

查看:161
本文介绍了在Active Directory中的在线计算机列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个片段的code到输出的所有计算机的列表我的网络上(的语言jscript.net,但它只是一个小的操作的C#)。

I'm using this snippet of code to output a list of all the computers on my network (the language is jscript.net, but it's just a small manipulation of C#).

    var parentEntry = new DirectoryEntry();

    parentEntry.Path = "WinNT:";
    for(var childEntry in parentEntry.Children) {
        if(childEntry.SchemaClassName == "Domain") {
            var parentDomain = new TreeNode(childEntry.Name); 
            this.treeView1.Nodes.Add(parentDomain);

            var subChildEntry : DirectoryEntry;
            var subParentEntry = new DirectoryEntry();
            subParentEntry.Path = "WinNT://" + childEntry.Name;
            for(subChildEntry in subParentEntry.Children) {
                var newNode1 = new TreeNode(subChildEntry.Name);
                if(subChildEntry.SchemaClassName == "Computer") {
                    parentDomain.Nodes.Add(newNode1);
                }
            }
        }

    }

我有2个问题是:

I have 2 issues with this:

1),这是非常缓慢。有大约100台计算机显示,大约需要1分钟加载。

1) It is extremely slow. There's about 100 computers showing, and it takes about 1 minute to load.

2)我想这是目前在线计算机只有一个列表

这是可以做到,因为我见过的其他节目做的,他们是要快得多,还他们能够在网上只显示的。

This can be done because I've seen other programs doing it and they are much faster, also they're able to show only the ones online.

我缺少的东西?

推荐答案

我知道这是一个有点老,但对于其他人......这个片段将使用在2-3秒内AD域返回一个760的计算机名称.. ..A显著改善....享受!

I know it's a bit old, but for others...this snippet will return a 760 computer names from a domain using AD within 2-3 seconds....a significant improvement....enjoy!

    Friend Shared Function DomainComputers() As Generic.List(Of String)

    ' Add a Reference to System.DirectoryServices

    Dim Result As New Generic.List(Of String)

    Dim ComputerName As String = Nothing
    Dim SRC As SearchResultCollection = Nothing
    Dim Searcher As DirectorySearcher = Nothing

    Try

        Searcher = New DirectorySearcher("(objectCategory=computer)", {"Name"})

        Searcher.Sort = New SortOption("Name", SortDirection.Ascending)
        Searcher.Tombstone = False

        SRC = Searcher.FindAll

        For Each Item As SearchResult In SRC
            ComputerName = Item.Properties("Name")(0)
            Result.Add(ComputerName)
        Next

    Catch ex As Exception

    End Try

    Return Result

End Function

这篇关于在Active Directory中的在线计算机列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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