Access is denied to the network printers for ASP.NET App

Last Reply 11 days ago By dharmendr

Posted 17 days ago

I have instaled application on a server. I want to display network printers in a dropdown and i use this codes to achive that goal:

Protected Overrides Sub LoadPrinters()  
        Dim permison As New PrintingPermission(PrintingPermissionLevel.AllPrinting)  
        If Not IsPostBack Then  
            Dim strPrinter As String  
            Dim li As ListItem  
            dlPrinters.Items.Add(New ListItem("Select Printer", ""))  
            For Each strPrinter In System.Drawing.Printing.PrinterSettings.InstalledPrinters  
        End If  

Also i try this code:


Private Sub PrinterList()  
    ' USING WMI. (Windows Management Instrumentation)  
    Dim objMS As System.Management.ManagementScope = _  
        New System.Management.ManagementScope(ManagementPath.DefaultPath)  
    Dim objQuery As SelectQuery = New SelectQuery("SELECT * FROM Win32_Printer")  
    Dim objMOS As ManagementObjectSearcher = New ManagementObjectSearcher(objMS, objQuery)  
    Dim objMOC As System.Management.ManagementObjectCollection = objMOS.Get()  
    dlPrinters.Items.Add(New ListItem("Select Printer", ""))  
    For Each Printers As ManagementObject In objMOC  
        If CBool(Printers("Local")) Then                        ' LOCAL PRINTERS.  
        End If  
        If CBool(Printers("Network")) Then                      ' ALL NETWORK PRINTERS.  
        End If  
    Next Printers  
End Sub  
In both scenarios i cannot see network printers in the dropdown list and if i use second code i can see error: Access is denied.
My application is using impersonate account with full permision to the network and printers. What else can make the problems? 
You are viewing reply posted by: dharmendr 11 days ago.
Posted 11 days ago

Access denied is an error message displayed when you do not have appropriate access rights.

If you are being denied access to a network share, Intranet or the Internet and are receiving the access denied message you need permission to gain access.

Contact the administrator or individual responsible for that network resource to request the appropriate rights.