Friday, 23 September 2011

Delivering custom Citrix settings based on Client Name or IP Address

In a school or even enterprise environment you might have the requirement the closest printers or even network drives based on a devices location. Citrix has included a great set of printer management tools with Xendesktop 5.5, very simply these work by mapping printers on the thin client itself and then passing them through to the virtual desktop. With different endpoints running different operating systems and different architectures this can be tricky, so we have opted for a different solution.


The "HKLM\Software\Citrix\ICA\Session" registry key

This registry key contains a number of extremely useful values including Client IP Address, Client Name and Client Version. These values can be used in any number of ways to tailor delivery of settings to the virtual desktop.

One example might be installing a printer onto thin clients sitting in a specific VLAN, you can target them with a group policy based login script by checking the "HKLM\Software\Citrix\ICA\Session","ClientAddress" REG_SZ value.



Mapping printers via Client Name

I prefer to target my printers via "ClientName". When I build a set of thin clients for a specific area, lets take the Library for example I name them VDIC-LIB01 LIB02 LIB03 (VDIC for VDI client and LIB to specify Library). Of course if you were doing a large number of clients it might be easier to put them in their own VLAN and target them by IP address with the "ClientAddress" value and forget about individually naming each client.

As I am using the Kixtart scripting language for my existing logon script I am going to leverage that for my virtual desktop printer mapping, my script for mapping a printer based on "ClientName" reads as follows.

  $citrixcliname=READVALUE("HKLM\SOFTWARE\Citrix\ICA\Session", "ClientName")
  If InStr($citrixcliname,"VDIC-LIB")
    addprinterconnection("\\printserver.domain.local\LibraryStudent-Kyocera400kx")
    SetDefaultPrinter("\\printserver.domain.local\LibraryStudent-Kyocera400kx")
  endif
And here is an example based on "ClientAddress", it looks for "192.168.10" in the IP address.
  $citrixcliaddr=READVALUE("HKLM\SOFTWARE\Citrix\ICA\Session", "ClientAddress")
  If InStr($citrixcliaddr,"192.168.10.")
    addprinterconnection("\\printserver.domain.local\LibraryStudent-Kyocera400kx")
    SetDefaultPrinter("\\printserver.domain.local\LibraryStudent-Kyocera400kx")
  endif
This is an extremely simple but powerful way to target thin clients in specific areas and deliver any settings you want.



Speeding up the mapping process

I strongly recommend you pre-install all the printer drivers you are planning to map as part of your login script into the virtual desktop image. This will dramatically cut down the printer mapping time as the driver is already installed. The different is something like 5-30 seconds per printer you are mapping, depending on how heavy the driver installation is.

No comments:

Post a Comment