如何确定打印机安装在哪个服务器上

发布于 2024-12-23 08:13:06 字数 128 浏览 1 评论 0原文

如果我在 Active Directory 中查找打印机,有什么方法可以确定它安装在哪个服务器上?如果我在 Active Direcory 控制台中查找打印机,属性标题会告诉我服务器,如何以编程方式确定该值?

编辑:语言是C#

If I look up a printer in Active Directory, is there any way to determine the server it is installed on? If I look up the printer in the Active Direcory console, the properties caption tells me the server, how can I determine this value programatically?

Edit: Language is C#

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不甘平庸 2024-12-30 08:13:06

AD 中 printQueue 对象的 serverName 属性或 uncName 属性可能就是您想要的。

The serverName attribute or uncName attribute of the printQueue object in AD is likely what you want.

末が日狂欢 2024-12-30 08:13:06

为了构建 alexn 提供的链接中的答案,这是我编写的一个程序,它将打印出计算机上每台打印机的服务器信息:

        String server = String.Empty;

        // For each printer installed on this computer
        foreach (string printerName in PrinterSettings.InstalledPrinters) {
            // Build a query to find printers named [printerName]
            string query = string.Format("SELECT * from Win32_Printer WHERE Name LIKE '%{0}'", printerName);

            // Use the ManagementObjectSearcher class to find Win32_Printer's that meet the criteria we specified in [query]
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
            ManagementObjectCollection coll = searcher.Get();

            // For each printer (ManagementObject) found, iterate through all the properties
            foreach (ManagementObject printer in coll) {
                foreach (PropertyData property in printer.Properties) {
                    // Get the server (or IP address) from the PortName property of the printer
                    if (property.Name.Equals("PortName")) {
                        server = property.Value as String;
                        Console.WriteLine("Server for " + printerName + " is " + server);
                    }
                }
            }
        }

打印机的所有其他属性也可以作为 PropertyData 提供。

To build on the answer in the link alexn provided, here's a program I wrote that will print out the server information for every printer on a computer:

        String server = String.Empty;

        // For each printer installed on this computer
        foreach (string printerName in PrinterSettings.InstalledPrinters) {
            // Build a query to find printers named [printerName]
            string query = string.Format("SELECT * from Win32_Printer WHERE Name LIKE '%{0}'", printerName);

            // Use the ManagementObjectSearcher class to find Win32_Printer's that meet the criteria we specified in [query]
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
            ManagementObjectCollection coll = searcher.Get();

            // For each printer (ManagementObject) found, iterate through all the properties
            foreach (ManagementObject printer in coll) {
                foreach (PropertyData property in printer.Properties) {
                    // Get the server (or IP address) from the PortName property of the printer
                    if (property.Name.Equals("PortName")) {
                        server = property.Value as String;
                        Console.WriteLine("Server for " + printerName + " is " + server);
                    }
                }
            }
        }

All the other properties of the printer are available as PropertyData as well.

安稳善良 2024-12-30 08:13:06

要查找共享打印机,请单击“桌面”,双击“网络”,双击连接打印机的计算机的名称,然后双击要在 Windows SBS 控制台中列出的打印机。

To find a shared printer, click Desktop, double-click Network, double-click the name of the computer to which the printer is attached, and then double-click the printer that you want to list in the Windows SBS Console.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文