469,909 Members | 2,041 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

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 5734
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Stephan Bour | last post: by
5 posts views Thread by Rik Hemsley | last post: by
1 post views Thread by Liverpool fan | last post: by
9 posts views Thread by =?Utf-8?B?Sm9obiBBdXN0aW4=?= | last post: by
reply views Thread by Peter Duniho | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.