Hi All,
I have gotten some great help on this site and was hoping to figure this problem out. What I am trying to do is to dynamically populate a list of available printers in a drop down box users can select from. I am connecting to AD in 2003 to get the printer info and want to "import" it dynamically into an hta so a user can select a location, then based on the selection, come up w/ a list of available printers for that locations. Confused yet ? I found this bit of code on another site yesterday and was wondering if anyone had any suggestions for intergrating this into a HTA ???
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://ou=bafw, ou=us,DC=behrgroup,DC=net' 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
Wscript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
Wscript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
objRecordSet.MoveNext
Loop
I have gotten some great help on this site and was hoping to figure this problem out. What I am trying to do is to dynamically populate a list of available printers in a drop down box users can select from. I am connecting to AD in 2003 to get the printer info and want to "import" it dynamically into an hta so a user can select a location, then based on the selection, come up w/ a list of available printers for that locations. Confused yet ? I found this bit of code on another site yesterday and was wondering if anyone had any suggestions for intergrating this into a HTA ???
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://ou=bafw, ou=us,DC=behrgroup,DC=net' 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
Wscript.Echo "Printer Name: " & objRecordSet.Fields("printerName").Value
Wscript.Echo "Server Name: " & objRecordSet.Fields("serverName").Value
objRecordSet.MoveNext
Loop