Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 670
  • Last Modified:

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

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
stevestark
Asked:
stevestark
3 Solutions
 
ketelhuisCommented:
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
 
oBdACommented:
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
 
haresh-nycCommented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now