TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jordan Trajkov
1.6k
163
10.6k
Access is denied to the network printers for ASP.NET App
Sep 26 2019 11:41 PM
I have instaled asp.net 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.Clear()
dlPrinters.Items.Add(
New
ListItem(
"Select Printer"
,
""
))
For
Each
strPrinter
In
System.Drawing.Printing.PrinterSettings.InstalledPrinters
dlPrinters.Items.Add(strPrinter)
Next
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)
objMS.Connect()
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.Clear()
dlPrinters.Items.Add(
New
ListItem(
"Select Printer"
,
""
))
For
Each
Printers
As
ManagementObject
In
objMOC
If
CBool
(Printers(
"Local"
))
Then
' LOCAL PRINTERS.
dlPrinters.Items.Add(Printers(
"Name"
))
End
If
If
CBool
(Printers(
"Network"
))
Then
' ALL NETWORK PRINTERS.
dlPrinters.Items.Add(Printers(
"Name"
))
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?
Reply
Answers (
2
)
How can I unload xps file in document viewer
Disable particulate time slots in telerik kendo scheduler