Connecting Tech Pros Worldwide Help | Site Map

network printing through asp.net webservice

Newbie
 
Join Date: Feb 2008
Posts: 2
#1: Feb 24 '08
I am working on one application where i want to print a file on network printer through asp.net webservice. When i invoke webservice from a application which is on the local machine where my webservice is running it prints properly, but when i call webservice from a application which is on other machine then it gives an error as "Unauthorized access to file". I hav given all rights to printer,users in IIS as well as in printer rights. Also windows authentication is enabled in IIS and anonymous access is also allowed through IIS. What is the problem????
Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#2: Feb 24 '08

re: network printing through asp.net webservice


So you are hosting a webservice for your internal purpose,

And the unauthorized access is turned out when another machine tries to call this service.

My first question would be what are the inputs sent to the webservice?

If it takes the file name, then you clearly have a problem, as users might send a file c:\Program Files\Yada\Yada.Doc

or
\\PrintingComputer4\Program Files\Yada\Yada.Doc

What i think you should do is either copy the file to the server , or send the file as a stream to the webservice which will then store it on its local drive and print it.

The serer trying to access the client PC is definitely a security exception
Newbie
 
Join Date: Feb 2008
Posts: 2
#3: Feb 24 '08

re: network printing through asp.net webservice


Quote:

Originally Posted by Shashi Sadasivan

So you are hosting a webservice for your internal purpose,

And the unauthorized access is turned out when another machine tries to call this service.

My first question would be what are the inputs sent to the webservice?

If it takes the file name, then you clearly have a problem, as users might send a file c:\Program Files\Yada\Yada.Doc

or
\\PrintingComputer4\Program Files\Yada\Yada.Doc

What i think you should do is either copy the file to the server , or send the file as a stream to the webservice which will then store it on its local drive and print it.

The serer trying to access the client PC is definitely a security exception



My files that are to be printed are been created on the machine where webservice is located and i want to print that files to a printer which is attached on other machine which i am not able to do. It properly prints on local machine when webservice i called from other machine but not on network printer. i have added that printer on my machine also as it i shared and also hav given all rights. The file prints when i print it explicitly by giving a command in DOS. The only problem is when i give the file c:\abc.txt which is on webservice machine to \\machine_name\printer_name which is a n/w printer it doesnt print from code. I am using Printer Document and Printer Settings object and printing thru RawPrinter method. So there is any special code to be written in webservice like creating WindowPrincipal Obj or WindowsIdentity Obj??..No inputs are passed to webmethod. The file is passed in RawPrinter method and file is located on same machine where webservice is located, only printer is n/w printer. Also when the file is located in the Bin Dir of webservice it gives same problem. Pls help!!!!
Reply


Similar .NET Framework bytes