473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

REPOST: User add Printers via Web page?

Someone must have done this before?!?

I have VBS code that will Enumerate all the Printers in the AD and Add the
Printer Connection to the client... I'm just not a web developer so I need
some example code or hand-holding on the web integration portion.

Anyone?
"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
Does anyone know of an ASP page that will query the AD and list all the
printers so the users can "click to add" printer mappings to their profile?

thanks!
Aaron

--
Tek Recycle
www.TekRecycle.com
* your source for the best prices on Sony InfoLithium batteries,
camera/camcorder accessories, Home electronics and
small appliances, and tools!

Jul 19 '05 #1
5 5877
You'd have to do this in two parts.
The ASP part would do the enumeration....which should be nearly identical to
te code you have.
Then, client side script would install the printer on the client (if the
user grants permission)

You've posted this to many newsgroups, why? Most of the groups you selected
are irrelevant.

Post your VBS script and I'm sure someone can assist.

"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:u1*************@TK2MSFTNGP10.phx.gbl...
Someone must have done this before?!?

I have VBS code that will Enumerate all the Printers in the AD and Add the
Printer Connection to the client... I'm just not a web developer so I need
some example code or hand-holding on the web integration portion.

Anyone?
"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
Does anyone know of an ASP page that will query the AD and list all the
printers so the users can "click to add" printer mappings to their

profile?


thanks!
Aaron

--
Tek Recycle
www.TekRecycle.com
* your source for the best prices on Sony InfoLithium batteries,
camera/camcorder accessories, Home electronics and
small appliances, and tools!


Jul 19 '05 #2
DJL
Post your vbscript?

"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:u1*************@TK2MSFTNGP10.phx.gbl...
Someone must have done this before?!?

I have VBS code that will Enumerate all the Printers in the AD and Add the
Printer Connection to the client... I'm just not a web developer so I need
some example code or hand-holding on the web integration portion.

Anyone?
"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:eN**************@TK2MSFTNGP12.phx.gbl...
Does anyone know of an ASP page that will query the AD and list all the
printers so the users can "click to add" printer mappings to their

profile?


thanks!
Aaron

--
Tek Recycle
www.TekRecycle.com
* your source for the best prices on Sony InfoLithium batteries,
camera/camcorder accessories, Home electronics and
small appliances, and tools!


Jul 19 '05 #3
Here's the ASP I has so far (commented)...

------ printers.asp --------
<%
Option Explicit
Response.Buffer = True
%>

<html>
<head>
<style>
body, p, td { font-family:Verdana;font-size:8pt; }
</style>
</head>

<body>
<%
EnumADprinters

%>

</body>
</html>

<%
' *************************************************
' Enumerate all AD printers
'
' reference:
' Microsoft:
http://eu.microsoft.com/technet/tree...net/scriptcent
er/printing/default.asp
' *************************************************
Function EnumADprinters()

Dim objConnection, objCommand, objRecordSet
Dim oPrinterName, oServerName

Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, serverName from " _
& " 'LDAP://DC=corp,DC=binghameq,DC=com' where objectClass='printQueue'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF ' should place data into array - TODO
Set oPrinterName = objRecordSet.Fields("printerName").Value
Set oServerName = objRecordSet.Fields("serverName").Value
'Wscript.Echo "Printer Name: " & oPrinterName & vbcr & "Server Name: "
& oServerName

' NOTE: would be better to put into array and pass array to function to
build table... not sure how to do this.

' Create table to show Printers
Response.Write "<table align=""center"" border=""1""" & _
" width=""80%"""
Response.Write " cellspacing=""0"" cellpadding=""5""" & _
" bordercolor=""black"">"
Response.Write vbcrlf
BuildPrinterTable ' send to function to build rows/columns
Response.Write "</table>"

objRecordSet.MoveNext

Loop

End Function

' *************************************************
' Display Printers from Active Directory in table
' *************************************************
Function BuildPrinterTable(oPrinterName,oServerName)

' Build Row
Response.Write "<tr>" & vbcrlf

' Build Column
Response.Write "<td>"
Response.Write oPrinterName
Response.Write "</td>"
Response.Write "<td>"
Response.Write oServerName
Response.Write "</td>"
Response.Write "<td>"
Response.Write "<FORM NAME=" & oPrinterName &" ACTION=" & MapPrinter() & "
METHOD=""get"" ><input type=""checkbox"" name=""box"" value=" & oPrinterName
& "></form>" ' Creates Form for each Printer -- this must execute on the
CLIENT side
Response.Write "</td>"

Response.Write "</tr>" & vbcrlf

End Function

' *************************************************
' Map Printers to User Profile
' *************************************************
Function MapPrinter(oServerName,oPrinterName)

Set strPrinter = "\\" & oServerName &"\" & oPrinterName ' complete
Printer path and name
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection(strPrinter)
' Alternative method (user & pw optional):
' WshNetwork.AddPrinterConnection
"LPT1",strPrinter,FALSE,"Domain\userid","passw ord"
End Function

%>
"DJL" <dj******@hotmail.com> wrote in message
news:#c*************@TK2MSFTNGP12.phx.gbl...
Post your vbscript?

"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:u1*************@TK2MSFTNGP10.phx.gbl...
Someone must have done this before?!?

I have VBS code that will Enumerate all the Printers in the AD and Add the Printer Connection to the client... I'm just not a web developer so I need some example code or hand-holding on the web integration portion.

Anyone?
"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message news:eN**************@TK2MSFTNGP12.phx.gbl...
Does anyone know of an ASP page that will query the AD and list all the printers so the users can "click to add" printer mappings to their

profile?


thanks!
Aaron

--
Tek Recycle
www.TekRecycle.com
* your source for the best prices on Sony InfoLithium batteries,
camera/camcorder accessories, Home electronics and
small appliances, and tools!



Jul 19 '05 #4
I need help passing the info from the server side -> web page display ->
client side

Here's the .VBS I have so far (commented)...

---------- printers.asp -------------

<%
Option Explicit
Response.Buffer = True
%>

<html>
<head>
<style>
body, p, td { font-family:Verdana;font-size:8pt; }
</style>
</head>

<body>
<%
EnumADprinters

%>

</body>
</html>

<%
' *************************************************
' Enumerate all AD printers
'
' reference:
' Microsoft:
http://eu.microsoft.com/technet/tree...net/scriptcent
er/printing/default.asp
' *************************************************
Function EnumADprinters()

Dim objConnection, objCommand, objRecordSet
Dim oPrinterName, oServerName

Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, serverName from " _
& " 'LDAP://DC=corp,DC=binghameq,DC=com' where objectClass='printQueue'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF ' should place data into array - TODO
Set oPrinterName = objRecordSet.Fields("printerName").Value
Set oServerName = objRecordSet.Fields("serverName").Value
'Wscript.Echo "Printer Name: " & oPrinterName & vbcr & "Server Name: "
& oServerName

' NOTE: would be better to put into array and pass array to function to
build table... not sure how to do this.

' Create table to show Printers
Response.Write "<table align=""center"" border=""1""" & _
" width=""80%"""
Response.Write " cellspacing=""0"" cellpadding=""5""" & _
" bordercolor=""black"">"
Response.Write vbcrlf
BuildPrinterTable ' send to function to build rows/columns
Response.Write "</table>"

objRecordSet.MoveNext

Loop

End Function

' *************************************************
' Display Printers from Active Directory in table
' *************************************************
Function BuildPrinterTable(oPrinterName,oServerName)

' Build Row
Response.Write "<tr>" & vbcrlf

' Build Column
Response.Write "<td>"
Response.Write oPrinterName
Response.Write "</td>"
Response.Write "<td>"
Response.Write oServerName
Response.Write "</td>"
Response.Write "<td>"
Response.Write "<FORM NAME=" & oPrinterName &" ACTION=" & MapPrinter() & "
METHOD=""get"" ><input type=""checkbox"" name=""box"" value=" & oPrinterName
& "></form>" ' Creates Form for each Printer -- this must execute on the
CLIENT side
Response.Write "</td>"

Response.Write "</tr>" & vbcrlf

End Function

' *************************************************
' Map Printers to User Profile
' *************************************************
Function MapPrinter(oServerName,oPrinterName)

Set strPrinter = "\\" & oServerName &"\" & oPrinterName ' complete
Printer path and name
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection(strPrinter)
' Alternative method (user & pw optional):
' WshNetwork.AddPrinterConnection
"LPT1",strPrinter,FALSE,"Domain\userid","passw ord"
End Function

%>

"Tom B" <sh*****@hotmail.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
You'd have to do this in two parts.
The ASP part would do the enumeration....which should be nearly identical to te code you have.
Then, client side script would install the printer on the client (if the
user grants permission)

You've posted this to many newsgroups, why? Most of the groups you selected are irrelevant.

Post your VBS script and I'm sure someone can assist.

"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:u1*************@TK2MSFTNGP10.phx.gbl...
Someone must have done this before?!?

I have VBS code that will Enumerate all the Printers in the AD and Add the Printer Connection to the client... I'm just not a web developer so I need some example code or hand-holding on the web integration portion.

Anyone?
"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message news:eN**************@TK2MSFTNGP12.phx.gbl...
Does anyone know of an ASP page that will query the AD and list all the printers so the users can "click to add" printer mappings to their

profile?


thanks!
Aaron

--
Tek Recycle
www.TekRecycle.com
* your source for the best prices on Sony InfoLithium batteries,
camera/camcorder accessories, Home electronics and
small appliances, and tools!



Jul 19 '05 #5
Change your MapPrinter to client side
<SCRIPT LANGUAGE=VBScript>
Function MapPrinter....
</SCRIPT>

Call the function when the user clicks a button
<input type=button onClick="MapPrinter 'BobServer','BobPrinter'"
Value="\\BobServer\BobPrinter">
"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
I need help passing the info from the server side -> web page display ->
client side

Here's the .VBS I have so far (commented)...

---------- printers.asp -------------

<%
Option Explicit
Response.Buffer = True
%>

<html>
<head>
<style>
body, p, td { font-family:Verdana;font-size:8pt; }
</style>
</head>

<body>
<%
EnumADprinters

%>

</body>
</html>

<%
' *************************************************
' Enumerate all AD printers
'
' reference:
' Microsoft:
http://eu.microsoft.com/technet/tree...net/scriptcent er/printing/default.asp
' *************************************************
Function EnumADprinters()

Dim objConnection, objCommand, objRecordSet
Dim oPrinterName, oServerName

Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "Select printerName, serverName from " _
& " 'LDAP://DC=corp,DC=binghameq,DC=com' where objectClass='printQueue'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF ' should place data into array - TODO
Set oPrinterName = objRecordSet.Fields("printerName").Value
Set oServerName = objRecordSet.Fields("serverName").Value
'Wscript.Echo "Printer Name: " & oPrinterName & vbcr & "Server Name: " & oServerName

' NOTE: would be better to put into array and pass array to function to
build table... not sure how to do this.

' Create table to show Printers
Response.Write "<table align=""center"" border=""1""" & _
" width=""80%"""
Response.Write " cellspacing=""0"" cellpadding=""5""" & _
" bordercolor=""black"">"
Response.Write vbcrlf
BuildPrinterTable ' send to function to build rows/columns
Response.Write "</table>"

objRecordSet.MoveNext

Loop

End Function

' *************************************************
' Display Printers from Active Directory in table
' *************************************************
Function BuildPrinterTable(oPrinterName,oServerName)

' Build Row
Response.Write "<tr>" & vbcrlf

' Build Column
Response.Write "<td>"
Response.Write oPrinterName
Response.Write "</td>"
Response.Write "<td>"
Response.Write oServerName
Response.Write "</td>"
Response.Write "<td>"
Response.Write "<FORM NAME=" & oPrinterName &" ACTION=" & MapPrinter() & " METHOD=""get"" ><input type=""checkbox"" name=""box"" value=" & oPrinterName & "></form>" ' Creates Form for each Printer -- this must execute on the
CLIENT side
Response.Write "</td>"

Response.Write "</tr>" & vbcrlf

End Function

' *************************************************
' Map Printers to User Profile
' *************************************************
Function MapPrinter(oServerName,oPrinterName)

Set strPrinter = "\\" & oServerName &"\" & oPrinterName ' complete
Printer path and name
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection(strPrinter)
' Alternative method (user & pw optional):
' WshNetwork.AddPrinterConnection
"LPT1",strPrinter,FALSE,"Domain\userid","passw ord"
End Function

%>

"Tom B" <sh*****@hotmail.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
You'd have to do this in two parts.
The ASP part would do the enumeration....which should be nearly identical
to
te code you have.
Then, client side script would install the printer on the client (if the
user grants permission)

You've posted this to many newsgroups, why? Most of the groups you

selected
are irrelevant.

Post your VBS script and I'm sure someone can assist.

"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message news:u1*************@TK2MSFTNGP10.phx.gbl...
Someone must have done this before?!?

I have VBS code that will Enumerate all the Printers in the AD and Add

the Printer Connection to the client... I'm just not a web developer so I need some example code or hand-holding on the web integration portion.

Anyone?
"Aaron_TekRecycle.com" <aaron_NAME@DOMAIN_tekrecycle.com> wrote in message news:eN**************@TK2MSFTNGP12.phx.gbl...
> Does anyone know of an ASP page that will query the AD and list all the > printers so the users can "click to add" printer mappings to their
profile?
>
>
> thanks!
> Aaron
>
> --
> Tek Recycle
> www.TekRecycle.com
> * your source for the best prices on Sony InfoLithium batteries,
> camera/camcorder accessories, Home electronics and
> small appliances, and tools!
>
>



Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Ortt | last post by:
I appologise for reposting this but I have been trying to find a solution all week with no avail and I was hoping a repost might help somebody more knowledgable than myself to spot the message... ...
2
by: Stephan Bour | last post by:
I repost this since I know how much some list people hate html posts ;-) Hi, I have a query page were users can check previous orders according to a number of parameters. The query results are...
5
by: Rik Hemsley | last post by:
Hi, My ASP.NET application (running on IIS) doesn't see any of the printers installed on its server. I'd like it to be able to see, and print to, all printers. Is there a way to give the...
1
by: lecnac | last post by:
Sorry for the repost. I must have done something wrong when I tried to post my reply (I can't seem to find it). Anyway, I'd really appreciate any help that anyone could provide. My issue is...
1
by: Liverpool fan | last post by:
I have a simple user control that consists of a lebel and a dropdown list that I am using for page navigation. I want to cache this control so that it is reused between pages, however when I add...
4
by: Rik Hemsley | last post by:
Hi, Our web application impersonates a domain user when it runs. Usually, the printers visible to the application are the same as those visible to the domain user. At one installation, the...
9
by: =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post by:
I have an app that prints entry tickets. If the printer driver is not set up exactly to detect the black mark on the back of the ticket, the tickets do not print correctly. Because of this, all...
0
by: Ravigwipro | last post by:
Hi, I m able to get the printers object to know what are the printers had been installed and all. here my requirement is i have to write a data from VB to MS Word. for the page setup i have to...
0
by: Peter Duniho | last post by:
On Wed, 23 Apr 2008 09:40:14 -0700, Al Meadows <fineware@fineware.com> wrote: This doesn't really seem to be a .NET or C# question. However, you may want to look at the driver settings...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.