Reply
Old June 24th, 2007 Top | #1
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Assign Printer on Location

How could one assign a user printers based on location. At the moment I can assign printers to everyone which is not always convenient. E.g.Printers in the English department can be seen from a user in the Art department.
How can i assign printers that are relevant to where the user is located at a certain department.
I only have one PC running Windows Server 2003 Enterprise, would I need another? thnx

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old June 24th, 2007 Top | #2
 
madmatt's Avatar
Bow Down to the King
Joined: April 2002
Location: New York
Posts: 13,312
Reputation: 4090
Power: 297

Default Re: Assign Printer on Location

Are the users logging in on the same computer each time or are they moving around? Command scripting would work for the first, but not for the second because Active Directory doesn't know where the computer is technically located.

madmatt is offline   Reply With Quote
Old June 24th, 2007 Top | #3
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

They would be logging into many machines as each department has say 5 clients for that department.
e.g. A user logs on (to any of the 5) at the English department and only have a choice to use printers in the English department. While a user doing the same thing in the ICT department only sees ICT department printers.

Would creating a script under Computer Configuration do the trick, (and bin the ones I have set that show them all printers). So the script is run to all who log in to those particular machines? But as to how to apply the script to an actual Computer I'm not sure.
hope thats clear

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old June 24th, 2007 Top | #4
 
madmatt's Avatar
Bow Down to the King
Joined: April 2002
Location: New York
Posts: 13,312
Reputation: 4090
Power: 297

Default Re: Assign Printer on Location

I didn't think of that idea. Put each of those computers into a different OU and you should be good to go.

madmatt is offline   Reply With Quote
Old June 24th, 2007 Top | #5
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

Originally Posted by madmatt View Post
I didn't think of that idea. Put each of those computers into a different OU and you should be good to go.
It didn't come off unfortunately. It ran the Computer Settings on user logon but nothing came off, not even an error.Surely though it should have worked.
Applying a startup script to a Computer to connect certain printers, it makes sense lol. Did you have another idea?

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old June 25th, 2007 Top | #6

OSNN Folding Team  
fitz's Avatar
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168

Default Re: Assign Printer on Location

From what I understand, you want whoever signs into an English dept computer to have the english dept printers connected and simlilar setups for other dept.

You can actually do a couple things:

1) Put computers into seperate dept based OU's
2) Put computers into seperate dept base groups.

In either case, you can use either a computer or user loginscript to map the printers. Computer startup may be a bit iffy since the computer may not have connected/authenticated/set up the secure session to the domain by the time the startup script runs (yes, computers authenticate to the domain!).

Depending on how your group policies are set to process user login scripts, you might have the same problems with user login scripts since it is technically possible to set policies to process logins before the computer is fully "up" and on the domain. Trust me, it took me a long time to track down why our login scripts weren't properly pulling domain info during login until I traced it down to this.

My advice would be to set your user login scripts to check either condition above on the computer account (either computer OU membership or computer group memberships) and map your printers accordingly.

Again, you need some scripting advice, lets start with what you have and go from there.
fitz is offline   Reply With Quote
Old June 25th, 2007 Top | #7
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

This is my current script as is:

Set WshNetwork = CreateObject("WScript.Network")

WshNetwork.AddWindowsPrinterConnection "\\JONNYSERV1\HP LaserJet 4100 Series PS"
WshNetwork.SetDefaultPrinter "\\JONNYSERV1\HP LaserJet 4100 Series PS"

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old June 25th, 2007 Top | #8

OSNN Folding Team  
fitz's Avatar
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168

Default Re: Assign Printer on Location

As I think about it, a computer script won't work. When you connect/map a printer, it is tied to the user profile.. since a user profile isn't loaded when a computer startup script runs, the printer has no profile to connect to.

You could, in theory, try to map a printer and copy that profile to the default profile. This will allow any new profile that is created to already have that printer connected. For existing users, you could either map them manually, or delete their profile and force them to generate a new one from the default profile (I don't recommend deleting existing profiles..). The downside of using the profile method, is anytime you add/replace/move a computer to a department, you'll have to remember to set this up each file.

A script solution is still more ideal to me for this reason.

Since a computer startup script won't work, you'll have to do it during the user login script. You still have to choices depending on your needs:

1) Put computers into seperate OU's and check the computer OU during the login script and map printers accordingly.
2) Put computers into groups and check computer group membership during the login script and map printers accordingly.

Checking the OU is quicker/faster to script, but some environments don't allow/don't want computer's in OU's based on location.. thus checking group membership would be used. If you're workplace doesn't mind seperate OU's for each location/dept for the computer accounts, which it sounds like your location, then use the OU.

Code:
'returns the LDAP Path (distinguished name) of the computer account
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
From there, it will return the full LDAP path of the computer account as a string (ie:"CN=MyComputerName,OU=Math,DC=Contessa,DC=com")
You would then search the LDAP string for your OU and using either a case statement or if/then's map your printers accordingly.

Searching the LDAP string can be done a number of ways depending on the complexity of your LDAP path and if you use commas in OU names, etc. If it's fairly simple (ie: no nested OU's, etc..)
Code:
'find where the OU section starts in the LDAP Path
intStart=InStr(0,strComputerDN,"OU=")

'if the OU section exists, process the ou name
if intStart <> 0 then 
    intEnd=InStr(intStart,strComputerDN,",")

    'extract just the ou= portion
    strOU = mid(strComputerDN,intStart,intEnd)

    Set objNetwork= CreateObject("WScript.Network")

    'depending on which ou, map printers (converted ou string to all lower case)
    select case lcase(strOU)
        case "ou=english"
            objNetwork.AddWindowsPrinterConnect "<printer path>"
            objNetwork.AddWindowsPrinterConnect "<printer path2>"
            objNewwork.SetDefaultPrinter "<defaultPritnerPath>"
        case "ou=math"
            <map printers for computers in math dept.>
    end select
end if
edit:
disclaimer - the code above is for example purposes only. It is only a skeleton/framework and really needs some error checking and other controls put in before being considered for production use.
fitz is offline   Reply With Quote
Old July 7th, 2007 Top | #9
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

OK, I decided to try this out on my test box (Server 2003 R2)

OU's:
-PUBLIC (2 two clients- pub1, pub2)
-NEO (1 client- neo-1)

using the following:

Code:
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
intStart=InStr(0,strComputerDN,"PUBLIC=")
if intStart <> 0 then 
    intEnd=InStr(intStart,strComputerDN,",")
strOU = mid(strComputerDN,intStart,intEnd)
   Set objNetwork= CreateObject("WScript.Network")
select case lcase(strOU)
        case "ou=PUBLIC"
            objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 1"
            objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 2"
            objNewwork.SetDefaultPrinter "\\JONNYSERV\HP 2000C 1"
        case "ou=NEO"
            objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 3"
            objNewwork.SetDefaultPrinter "\\JONNYSERV\HP 2000C 3"
      end select
end if
and got a error on:
Line: 3
Char: 1
Error: Invalid procedure call or argument: 'InStr'
Code: 800A0005
Source: Microsoft VBScript Runtime Error

Whats wrong? I know I'm such a pain on scripts

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old July 7th, 2007 Top | #10
 
madmatt's Avatar
Bow Down to the King
Joined: April 2002
Location: New York
Posts: 13,312
Reputation: 4090
Power: 297

Default Re: Assign Printer on Location

Try OU=PUBLIC

madmatt is offline   Reply With Quote
Old July 7th, 2007 Top | #11
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

Originally Posted by madmatt View Post
Try OU=PUBLIC
Still get the same error...

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old July 7th, 2007 Top | #12

OSNN Folding Team  
fitz's Avatar
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168

Default Re: Assign Printer on Location

as a quick test, after you pull the objSysInfo.Computername , do a:

"wscript.echo strComputerDN"

and comment out the rest of the script. Make sure it is returning a valid value
fitz is offline   Reply With Quote
Old July 7th, 2007 Top | #13
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

Originally Posted by fitz View Post
as a quick test, after you pull the objSysInfo.Computername , do a:

"wscript.echo strComputerDN"

and comment out the rest of the script. Make sure it is returning a valid value
Like this?

Code:
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = objSysInfo.ComputerName
"wscript.echo strComputerDN"
intStart=InStr(0,strComputerDN,"ou=PUBLIC")
if intStart <> 0 then 
    intEnd=InStr(intStart,strComputerDN,",")
strOU = mid(strComputerDN,intStart,intEnd)
   Set objNetwork= CreateObject("WScript.Network")
select case lcase(strOU)
        case "ou=PUBLIC"
            objNetwork.AddWindowsPrinterConnect "\\JONNYSERV\HP 2000C 1"
            objNetwork.AddWindowsPrinterConnect "\\JONNYSERv\HP 2000C 2"
            objNewwork.SetDefaultPrinter "HP 2000C 1"
        case "ou=NEO"
            objNetwork.AddWindowsPrinterConnect "HP 2000C 3"
            objNewwork.SetDefaultPrinter "HP 2000C 3"
      end select
end if
Error now reads: expected statement

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old July 8th, 2007 Top | #14

OSNN Folding Team  
fitz's Avatar
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168

Default Re: Assign Printer on Location

no.. without quotes around the wscript.echo ... and either delete or comment out the rest of the script
fitz is offline   Reply With Quote
Old July 8th, 2007 Top | #15
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

Windows Script Host returned the following:
Code:
CN=PUB1,OU=PUBLIC,DC=TESTSERV,DC=local
Seems fine to me

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old July 9th, 2007 Top | #16

OSNN Folding Team  
fitz's Avatar
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168

Default Re: Assign Printer on Location

well, let's start with trying to remove the start position so, your code would start like:
Code:
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = lcase(objSysInfo.ComputerName)
intStart=InStr(strComputerDN,"ou=")
fitz is offline   Reply With Quote
Old July 9th, 2007 Top | #17
 
jonny813's Avatar
OSNN Addict
Joined: December 2006
Posts: 88
Reputation: 60
Power: 67

Default Re: Assign Printer on Location

Originally Posted by fitz View Post
well, let's start with trying to remove the start position so, your code would start like:
Code:
set objSysInfo = CreateObject("ADSystemInfo")
strComputerDN = lcase(objSysInfo.ComputerName)
intStart=InStr(strComputerDN,"ou=")
OK, should I execute that or what?

Samsung Q210
Intel Core 2 Duo (Centrino 2) P8400 @ 2.26Ghz - 5.2
3GB Samsung 666Mhz RAM - 5.9
nVidia GeForce 9200M GS - 4.4(Aero), 5.1(Gaming)
320GB HD (5,400RPM) - 5.3
Windows Vista Ultimate SP1 (32bit)
jonny813 is offline   Reply With Quote
Old July 9th, 2007 Top | #18

OSNN Folding Team  
fitz's Avatar
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168

Default Re: Assign Printer on Location

that should just be the beginning of the script.. i expect you to do some work and thinking as well..
fitz is offline   Reply With Quote
Old July 21st, 2007 Top | #19
 
Nismo83's Avatar
OSNN AZN Addict
Joined: March 2004
Posts: 383
Reputation: 10
Power: 103

Default Re: Assign Printer on Location

Originally Posted by madmatt View Post
I didn't think of that idea. Put each of those computers into a different OU and you should be good to go.
not sure if this work but after sharing the printer, there's this security settings where we can set a specifically user to print, manage documents and etc.

CPU | AMD64 3000+ VENICE - RAM | 1GB DDR 333MHz HYNIX KVR - MOBO | GIGABYTE K8NSC - HDD | 200GB MAXTOR HDD, 120GB WD HDD, 80GB WD HDD, 40GB MAXTOR HDD - GFX | 256MB DDR3 GIGABYTE ATI X800PRO - SOUND | CREATIVE AUDIGY2ZS PLATINUM PRO - SPEAKER | LOGITECH Z680 DTS/DD - PSU | THERMALTAKE 420W PSU - OPTICAL | ASUS CDRW, ASUS DVD-ROM - MONITOR | VIEWSONIC E90f+ 19" FLAT - ROUTER | CNet ADSL ROUTER MODEM

Nismo83 is offline   Reply With Quote
Old July 25th, 2007 Top | #20
 
ScottFern's Avatar
IT guy
Joined: March 2007
Location: Chicago
Posts: 48
Reputation: 20
Power: 64

Default Re: Assign Printer on Location

I tried this command as a login script but I received an error:

rundll32 printui.dll,PrintUIEntry /ga /in /n\\hubdc1\AcctLJ2200 /y

Anything wrong with this command? Sorry to threadjack!
ScottFern is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create and assign common domain download storage philabraham Windows Server Systems 1 December 12th, 2006 2:00pm
assign dhcp addresses based on OU membership fimchick Windows Desktop Systems 5 April 6th, 2006 10:06pm
assign keys on keyboard Silvio Desktop Customisation 4 May 5th, 2003 10:08pm
Name the location... pc_tek Green Room 21 May 25th, 2002 3:23pm
How to assign specific User profiles with gpedit ? BoaVista Desktop Customisation 1 February 2nd, 2002 6:12pm