Hi Experts,
How to get the list of network printers over the current network /domain using C# and not from the local machine ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Jun 22, 2011, 11:23 AM
VulpesPosted Jun 22, 2011, 10:05 AM
Do you get any printers returned if you use PRINTER_ENUM_REMOTE with the Name argument set to "Print Provider!Domain" ?
If you can use Active Directory and the sample code is working, I'd be inclined to go with that.
Posted Jun 22, 2011, 9:10 AM
Thanks for your response. I was also looking the same link.
If I pass the enum value as "PRINTER_ENUM_NETWORK" it is not returning any printer details but if I change the enum value to
PRINTER_ENUM_LOCAL then it is returning all my local system printers.
For enumerating the N/W printer do I need domain Administrator ? Please suggest me.
I got an one more sample code to get all the n/w printers by using the Active Directory.
Imports System
Imports System.DirectoryServices
Public Class Foo
Public Shared Sub Main(args() As String)
Dim entry As New DirectoryEntry("LDAP://DC=redmond, DC=corp, DC=microsoft, DC=com")
Dim searcher As New DirectorySearcher(entry)
searcher.Filter = "(objectCategory=printQueue)"
Dim result As SearchResult
For Each result In searcher.FindAll()
Console.WriteLine(result.GetDirectoryEntry().Path)
Next
End Sub
End Class
Source Link : http://forums.asp.net/t/443425.aspx/1
VulpesPosted Jun 22, 2011, 8:32 AM
To get all network printers in the current domain, I think you'll need to call the API function EnumPrinters (http://msdn.microsoft.com/en-us/library/dd162692(VS.85).aspx) and pass it the PRINTER_ENUM_NETWORK flag. The printer information (including the name) will then be returned in an array of PRINTER_INFO_1 structs.
Try the following:
Posted Jun 22, 2011, 4:47 AM
VulpesPosted Jun 22, 2011, 4:22 AM
Here's some C# code to try: