Login | |
|
 |
RE: Script for mapping printers with username and passw... - 10/28/2005 1:51:03 AM
|
|
 |
|
| |
alienprotein
Posts: 44
Score: 0
Joined: 2/23/2005
From: USA
Status: offline
|
I don't know if it is possible to pass a username and password to the printer (Nor do I understand why one would need to), but I can share some of my login script what map's drives and printers. Perhaps you can add these laptops/users to a security group rather then passing a username and password. This is your big problem. quote:
The users are logged on their laptops with local administrator, the computers are member of our domain but they cant log on with their domain users (for reasons I don’t want to discuss here) If you can get the users logging onto the domain using windows authentication then you will not need to pass a username and password to a printer. How are the printers connected to the domain? (IP address or print server?) Are the users logged on locally, able to access other network (Domain) resources when connected to the local subnet? ********************************************************** Option Explicit '******************** '* Declare variables* '******************** Dim objNetwork, objUser, strGroup, WshNetwork Dim WScript, net Dim currentuser Dim Network Set objNetwork = CreateObject("WScript.Network") Set objUser = CreateObject("ADSystemInfo") Set currentuser = GetObject("LDAP://" & objUser.UserName) strGroup = LCase(Join(currentuser.MemberOf)) '************************************ '*SETTING THE PRINTERS, FOR EVERYONE* '************************************ Set net = CreateObject("WScript.Network") net.AddWindowsPrinterConnection "\\DA2UTL01\McK-15", "McK-15 (Color)" net.AddWindowsPrinterConnection "\\DA2UTL01\McK-20", "McK-20 (High Speed)" net.AddWindowsPrinterConnection "\\DA2UTL01\McK-30", "McK-30 (High Speed)" net.AddWindowsPrinterConnection "\\DA2UTL01\McK-40", "McK-40 (High Speed)" '************************************************************** '* SETTING ALL NETWORKDRIVES THAT ARE AVAILABLE FOR EVERY USER* '************************************************************** objNetwork.MapNetworkDrive "q:", "\\da1fls01\files" objNetwork.MapNetworkDrive "H:", "\\Da2dc201\home\" & objNetwork.UserName objNetwork.MapNetworkDrive "G:", "\\da2dc201\working_files" '******************************************** '*Installs Printers for the Tech Files group* '******************************************** If isMemberOf("Tech Files") Then objNetwork.MapNetworkDrive "T:", "\\da1fls02\Lit_Support" net.AddWindowsPrinterConnection "\\DA1UTL01\AK-73 (TF)", "AK-73 (TF)" net.AddWindowsPrinterConnection "\\DA1UTL01\AK-74 (Color)", "AK-74 (Color)" net.AddWindowsPrinterConnection "\\DA1UTL01\AK-75 (TF)", "AK-75 (TF)" net.AddWindowsPrinterConnection "\\DA1UTL01\AK-77 (MF)", "AK-77 (MF)" net.SetDefaultPrinter "\\DA1UTL01\AK-73 (TF)" End If Function isMemberOf(group) Dim user, found, temp found = False Set user = GetObject("WinNT://" & CreateObject("WScript.Network").UserDomain & "/" & CreateObject("WScript.Network").UserName & ",user") For Each temp In user.Groups If UCase(temp.Name) = UCase(group) Then found = True Exit For End If Next isMemberOf = found End Function
|
|
| |
|
|
|
 |
RE: Script for mapping printers with username and passw... - 11/1/2005 11:50:56 PM
|
|
 |
|
| |
mbouchard
Posts: 1894
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
|
2 possible options, both have not been tested 1. Authenticate to the server that the printer is on. Net Use \\server /USERNAME:domain/user password then map the printer. I know that I have done this manually when logged on as local Admin. 2. Take a look at AutoIT, www.hiddensoft.com, it has a function called RunAsSet, which essentially initializes a users crendtials during a Run operation. I have used this to elevate a regular user to admin which allowed me to run a vbscript as an admin. If you go this route, you could create an AutoIT script that contained input boxes for the username and password of the user. It would then use RunAsSet, set the user context, run your vbscript to map the printer then reset the userrights. One question, have the laptop users ever connected to the domain using the "wired" NIC instead of the wireless one? Reason I ask is that where I work, we also have had issues when trying to log onto the domain wirelessly and found that, mostly on XP, if a user logs in while physically connected to the network their username/password is cached locally. So, they could log on as themselves where ever they are, be it in the building or at home. They would only have access to the domain when they were are work. Sometimes they were able to run our login script but most times, after logging on, they would need to manually run the script. But they would have full access to the domain.
_____________________________
Mike For useful Scripting links see the Read Me First stickey! Always remember Search is your friend.
|
|
| |
|
|
|
 |
RE: Script for mapping printers with username and passw... - 1/10/2006 12:35:42 AM
|
|
 |
|
| |
Bartman
Posts: 11
Score: 0
Joined: 12/22/2005
Status: offline
|
This is a script I use to map users who are not on my domain to the shared drives. Perhaps it will work for you printer as well. As I am a beginner to vbs I can't guarantee this will work for you. But it has been tested and used here. But as you can see it is a very basic, simple script. I run this locally, not across the network. I would think you could edit it to work across the network but I don't know for sure. ********** Script ********************** option explicit dim u_name, p_word on error resume next u_name=inputbox("Enter your user name: ") u_name="IMR\" & u_name msgbox "The name you entered was " & u_name p_word=inputbox("Enter your password: ") 'msgbox "The paswword you entered was " & p_word Dim network Set network = Wscript.CreateObject("WScript.Network") 'Clear network drive mappings first 'Map to the network dirves ON Error Resume Next network.MapNetworkDrive "N:", "\\ServerName\Apps", "True", u_name, p_word network.MapNetworkDrive "P:", "\\ServerName\Public", "True", u_name, p_word network.MapNetworkDrive "S:", "\\ServerName\Shared", "True", u_name, p_word network.MapNetworkDrive "M:", "\\ServerName\Software", "True", u_name, p_word network.MapNetworkDrive "I:", "\\ServerName\IT", "True", u_name, p_word **************** End Script *************************
< Message edited by Bartman -- 1/10/2006 12:39:00 AM >
_____________________________
BARTMAN! Watch it dude!
|
|
| |
|
|
|
 |
RE: Script for mapping printers with username and passw... - 1/10/2006 1:45:08 AM
|
|
 |
|
| |
DiGiTAL.SkReAM
Posts: 1170
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
|
Try using: 'Method#1 Set oNet = WScript.CreateObject("WScript.Network") oNet.AddPrinterConnection("Printer1","\\server\printer",False,"domain\username","Password") The .AddPrinterConnection allows username/password to be passed to it, but the .AddWindowsPrinterConnection method does not. Give it shot, it may work for you. Otherwise, I would suggest doing what mbouchard suggested with a little bit of what Bartman said, and connecting to the IPC$ share on the server and then mapping the printer like so: 'Method#2 sUserName = InputBox("Please enter domain username","User Logon Prompt") sPassword = InputBox("Please enter the password for " & sUserName, "Password Prompt") Set oNet = WScript.CreateObject("WScript.Network") oNet.MapNetworkDrive "","\\server\IPC$",False,"domain\" & sUserName,sPassword oNet.AddWindowsPrinterConnection "\\server\printer" Either way should work, however I would think that method#2 would give the best results.
< Message edited by DiGiTAL.SkReAM -- 1/10/2006 1:50:10 AM >
_____________________________
"Would you like to touch my monkey?" - Dieter (Mike Meyers) "It is better to die like a tiger, than to live like a pussy." -Master Wong, from Balls of Fury
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|