我怎样才能找到企业中的所有网络打印机?打印机、企业、网络

2023-09-08 12:55:21 作者:ぺ書冩時光

当我去打印机和传真对话框,我可以点击添加打印机链接,选择网​​络打印机 ,那么在目录中查找打印机。从那里,我得到一个对话框,让我发现企业中的所有打印机。

When I go to Printers and Faxes dialog, I can click the Add a printer link, select Network Printer, then Find a printer in the directory. From there I get a dialog box which lets me find ALL printers in the enterprise.

我需要找到所有与我的code中的网络打印机。我怎样才能做到这一点?

I need to find all the network printers with my code. How can I do this?

请注意,我说的不是在企业连接到我的电脑网络打印机,但所有的网络打印机(我的工作场所有近4000打印机)。

Note that I am not talking about network printers that are connected to my PC, but all network printers in the enterprise (my workplace has almost 4000 printers).

P.S。打印服务器()。GetPrintQueues只返回与计算机相连的打印机。

P.S. PrintServer().GetPrintQueues only returns printers attached to the computer.

P.P.S。这里是什么,我希望有一个简短的视频: http://www.angryhacker.com/toys /FindAllPrinters/FindAllPrinters.html

P.P.S. Here is a short video of what I want: http://www.angryhacker.com/toys/FindAllPrinters/FindAllPrinters.html

推荐答案

的 DirectorySearche R,其中的 (对象类=打印机) (objectClass的=打印队列)应该做的伎俩。

DirectorySearcher with a filter for (objectClass=printer) (objectClass=printQueue)should do the trick.

using (var e = new DirectoryEntry("LDAP://DC=example,DC=com"))
    using (var s = new DirectorySearcher(e)) {
        s.Filter = "(objectClass=printQueue)";

        using (var c = s.FindAll()) {
            WL("Returned {0} objects", c.Count);
            foreach (SearchResult r in c) {
                WL("{0}", r.Path);
            }
        }
    }