Solved

Assigning printers based on location and user after logging in through a VPN connection.

Posted on 2004-04-07
5
656 Views
Last Modified: 2012-05-04
Clients:  Windows 2000/XP
Server:  Windows 2003 AD

Here is the process:  The user boots up the PC/Laptop.  They are presented with the CTRL-ALT-DEL screen.  When the user hits CTRL-ALT-DEL they are presented with the Cisco VPN 4.0+ version client login.  Once logged into the VPN, they can then log in to the OS where login scripts can then run.

Setup after logging in:  If it is the first time a user logs in to that PC, they do not have printers installed.  We have instructed everyone on how to simply add the printers, but they normally forget and then complain about it.

Goal:  We would like to use a login script to set up the printers automatically based on the user and the location of the user.  We have users that float between sites and need sometimes 3 printers installed at each site.  I am using the following script to automatically install the printers, but this installs the exact printers no matter which site they are located at:

REM This script adds a printer without the need of Add a Printer Wizard
REM It then sets the first printer added as the default printer
rundll32 printui.dll,PrintUIEntry /in /n \\server\printer
rundll32 printui.dll,PrintUIEntry /y /n "\\server\printer"

This script would be perfect if it weren't for the floating users.  

I would normally do this at the system level through group policy, but they do not receive the group policy when booting up because they must first connect to the Cisco VPN.  This limits my ability to deploy this via a script with the exception of a user login script.  

Any help would be appreciated.  Big points!
0
Comment
Question by:stevestark
5 Comments
 
LVL 3

Accepted Solution

by:
ketelhuis earned 168 total points
Comment Utility
Hi,

When you use kix, you can retrieve the ip-adsress of the users pc and, based on the ip-address, assign printers.

This off course only works when different sites have different subnets.

grtz,

Arnout
0
 
LVL 82

Assisted Solution

by:oBdA
oBdA earned 166 total points
Comment Utility
That script should work for you; it calculates the current subnet the user logs in from. All you have to do is add the labels and configure the printer mapping, as configured in the two example subnets. Note that the "real" subnet is calculated from the subnet mask, it's not just based on the IP octets!
Instead of the rundll32 command you're using, you can use con2prt.exe from the Zero Administration Kit as well; I like it better since, unlike the "rundll32 printui", it's a real command line tool.
If you need to map printers according to group membership, you can use the free ifmember.exe tool.

====8<----[logon.cmd]----
@echo off
setlocal
for /f "tokens=3-6 delims=:. " %%a in ('ipconfig ^| find /i "IP Address"') do (
  set IP1=%%a
  set IP2=%%b
  set IP3=%%c
  set IP4=%%d
)
set IPAddress=%IP1%.%IP2%.%IP3%.%IP4%
for /f "tokens=3-6 delims=:. " %%a in ('ipconfig ^| find /i "Subnet"') do (
  set /a SN1=%IP1% ^& %%a
  set /a SN2=%IP2% ^& %%b
  set /a SN3=%IP3% ^& %%c
  set /a SN4=%IP4% ^& %%d
)
set Subnet=%SN1%.%SN2%.%SN3%.%SN4%

echo Current IP address: %IPAddress%
echo Current Subnet:     %Subnet%
:: *** Check if the label for the subnet exists; if not, leave:
type "%~f0" | find ":[%Subnet%]" >NUL
if errorlevel 1 goto leave
goto :[%Subnet%]

:: *** Handle the different subnets:

:[192.168.1.0]
echo Mapping printers for %Subnet%:
con2prt.exe /c \\Subnet1PrintServer\Printer
goto leave

:[192.168.2.0]
echo Mapping printers for %Subnet%:
con2prt.exe /c \\Subnet2PrintServer\Printer
goto leave

:leave
====8<----[logon.cmd]----

How to Use Con2prt.exe to Connect to a Network Printer
http://support.microsoft.com/?kbid=181663

Zero Administration Kit
http://www.microsoft.com/ntworkstation/downloads/Recommended/Featured/NTZAK.asp

Resource Kits Free Tool Downloads: Ifmember.exe
http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o.asp
0
 
LVL 3

Assisted Solution

by:haresh-nyc
haresh-nyc earned 166 total points
Comment Utility
if the printer names are the same in each locaction,
you can take advantage of the user environment variable    LOGONSERVER.

what happens if you use the following:

rundll32 printui.dll,PrintUIEntry /in /n \\%logonserver%\printer1
rundll32 printui.dll,PrintUIEntry /y /n " \\%logonserver%\printer2

I'm assuming each user should by default become authenticated by the closest server to them,
and therefore the logonserver should be their local DC at that site.

please update us on the status.
thanks
haresh
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now