views:

184

answers:

2

Hi,

I have an ASP.NET application where user is Anonymous when he connects to website. Also I have a printing server inside network. I want to let this user to print to the network printer.

In order to print I have to use File.Copy command. When I do this I get "Access denied". So I tried to impersonate the user with credentials of user that is inside domain and has the rights to print to that specific printer.

The problem is this user has to be Administrator, and I cannot let him be the Administrator. When this user is not Administrator then the printing is not working ("Access denied").

I tried to use Network Credentials but I don't know how to set credentials to command File.Copy. This command doesn't have any extensions or overloading for credentials.

Any help will be appreciated :)

+1  A: 

You should just grant write access to the folder that you are copying to. Right click on the folder and choose Properties -> Security. Then add the user that you are impersonating in asp.net. You can do the same thing for the anonymous user, although it's a bit more complicated.

klausbyskov
A: 

Thank you for you answer. I cannot change security for the folder because I don't have a folder. I'm copying this file right to the network printer \serverName\printerName\fileName .

Katya