Printing to network printer on server

Last post 05-14-2008 11:32 PM by Benson Yu - MSFT. 3 replies.

Sort Posts:

  • Printing to network printer on server

    05-08-2008, 3:07 AM
    • Loading...
    • ibeme
    • Joined on 12-13-2007, 8:42 AM
    • Posts 16

    Hi,

    I'm using the following code to print:

    --------

    Dim myProcess As Process = New Process

    myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden

    myProcess.StartInfo.FileName = exe    'contains name of executable to run

    myProcess.StartInfo.Arguments = "/t " & """" & filename & """"

    myProcess.StartInfo.UseShellExecute = False

    myProcess.Start()

    myProcess.WaitForInputIdle()

    If myProcess.Responding Then

    myProcess.CloseMainWindow()

    Else

    myProcess.Kill()

    End If

    Threading.Thread.Sleep(5000)

    ----------

    The code works from my Visual Studio, but not after deploying to the server because there are no printers mapped for user ASPNET. I've done the following to get printers to map:

    1. Change Application Pool identity from Network Service to Local System

    2. Copy HKEY_CURRENT_USER\Printers\Connections (for valid user with printer mappings) to HKEY_USERS\.DEFAULT

    Still the printers aren't mapped though, unless I log onto the server myself and run it, in which case it is able to use the printer mappings for my login. Does anyone know what else I need to do to get printers to map for ASPNET user?

    Thanks,

    Rob

  • Re: Printing to network printer on server

    05-14-2008, 4:23 AM
    Answer

    Hi Rob,

    Since the web application works in the Visual Studio build-in Devlopment Server, it should be the Windows accont issue as you said.

    In my opinion, you can try to create a Windows login user on that server, and then create printer mappings for that user. At last, change the ASP.NET process identity to that Windows user. After finishing these steps, the process identity environment is similar to work with the Visual Studio build-in Devlopment Server (as you may know, running in Visual Studio build-in Devlopment Server the process identity is current Window login account).

    For your reference, if you do not want to put the new added Windows user in Loacl Admin group for security reason, you can refer to the default permissions for the ASPNET account in the following link, and assign same permissions to the new created Windows user as well. This article also introduces how to change the ASP.NET process identity by modifying the machine.config.

    Process and request identity in ASP.NET
    http://support.microsoft.com/kb/317012

    P.S. Since you mentioned application pool, I think your operating system is Windows Server 2003. For IIS 6.0, we can change the application pool identity instead of changing the process identity in machine.config.
     

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
  • Re: Printing to network printer on server

    05-14-2008, 6:02 AM
    • Loading...
    • ibeme
    • Joined on 12-13-2007, 8:42 AM
    • Posts 16

    Hi Benson,

     Thanks for your response. Apologies for the duplicate threads. It wasn't intentional. The first two attempts to post the message resulted in an error advising me to try again later. It wasn't until 12 or so hours later that I received confirmation that all threads had been posted.

    I have changed the application pool identity to Local System with no luck. Something else that I've realised upon researching this issue is that (if my understanding is correct) is that the ASPNET account isn't the culprit as we are using windows integrated security with impersonation. It's my understanding that this removes any involvement from the ASPNET account. The impersonated accounts that I have tried all have printers mapped when logging onto the server directly. It just seems that IIS is putting up a roadblock somewhere along the line.

    The printers that we are trying to map are network printers that exist on another server. We have unrestricted delegation enabled across our servers so the 'second hop' should not be an issue in that regard.

    One thing that I've come across, but don't have a full understanding of, is UNC shares in the IIS virtual directory. I've read about it being used in terms of file sharing and was wondering it would be usable for setting up a printer share that would then be available for all users.

    Any further comment or advice would be appreciated.

    regards,

    ibeme

     

  • Re: Printing to network printer on server

    05-14-2008, 11:32 PM

    ibeme:
    I have changed the application pool identity to Local System with no luck.
     

    Hi Rob,

    Thanks for your explanation. As far as I know, the "LocalSystem" account is not associated with any Windows login user account. That is why I suggest you to create a new Windows login account for test. In IIS 6.0 manager, instead of using the predefined “LocalSystem” account, please select the “Configurable” option with specific user name and password for the new Windows login account.

    For troubleshooting purpose, you can temporarily add that user in local “Administrators” group to separate the possible permission issue.

    Alternatively, you can use your current Windows login account as the ASP.NET process identity for test.

    LocalSystem Account
    http://msdn.microsoft.com/en-us/library/ms684190(VS.85).aspx

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
Page 1 of 1 (4 items)