3

I'm building an ASP.NET application where it prints some tags with a barcodes, the printers will be installed into local PCs and will be shared in the server where the application is hosted.

So my issue is related to the domain name, because the domain name where the printers are installed is different to the domain name where the server is. I tried to print from the local application and it prints correctly but when I try to print from the web, the following error is shown:

The RPC server is unavailable

I think it's a security issue, I tried to supplant the user that runs the application but even so the application does not works.

M4N
  • 94,805
  • 45
  • 217
  • 260

1 Answers1

1

Firstly, if you are printing you really shouldn't be creating a web app (or allow the user to print the barcode locally from the page).

If you must do it this way then you need to ensure that just before you execute your print code you impersonate a user that has permission on the domain to print the barcode. This code should help:-

using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) )
{
   ... 
   Print Code
   ...
}

The Impersonator class can be found here: http://www.codeproject.com/Articles/10090/A-small-C-Class-for-impersonating-a-User

M4N
  • 94,805
  • 45
  • 217
  • 260
Ross Dargan
  • 5,876
  • 4
  • 40
  • 53