C# 除非共享,否则打印机不可用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-01 08:48:25  来源:igfitidea点击:

Printers not available unless shared

提问by Ryan

We are using classic asp to call a C# dll and in the C# dll we are using System.Drawing.Printing.PrinterSettings.InstalledPrinters to get a list of availabe printers. If the printers are not shared they will not show up when a user trys to print. The Local System account can see and print to them from a VB6 dll and Administrators can print just fine from the C# dll as you might expect. Is there some sort of permissions we need to grant the user so these printers will be available?

我们使用经典的 asp 来调用 C# dll,在 C# dll 中,我们使用 System.Drawing.Printing.PrinterSettings.InstalledPrinters 来获取可用打印机列表。如果打印机未共享,当用户尝试打印时它们将不会显示。本地系统帐户可以从 VB6 dll 中查看并打印给它们,管理员可以从 C# dll 中正常打印,正如您所期望的那样。我们是否需要授予用户某种权限才能使用这些打印机?

回答by Tim Sullivan

As I recall, running a website uses the Network User account, which may not have permission to view local printers.

我记得,运行网站使用网络用户帐户,该帐户可能没有查看本地打印机的权限。

There was a page on MSDN that said how you can impersonate another user that might have access to the printers, but I've not been able to find it.

MSDN 上有一个页面说如何模拟另一个可能有权访问打印机的用户,但我找不到它。

Edit: I posted too soon. Here's the page.

编辑:我发布得太早了。这是页面

HTH

HTH

回答by Joel Lucsy

I'm fairly certain that impersonating a user or using their credentials does not constitute the ability to see the printers for that user. I believe explorer.exe reconnects all the network resources (shares/printers) upon logon.

我相当肯定,冒充用户或使用他们的凭据并不构成查看该用户的打印机的能力。我相信 explorer.exe 会在登录时重新连接所有网络资源(共享/打印机)。