dec_ituk
(Just in Town)
2016-06-21 05:35 PM
Selecting Default Printer

Hi All,

I am trying to set my default printer on my login script. I am using kix version 4.66.

I have an attribute in Active Directory saved in the 'notes' (Info) section for each user. In the notes I have "DEFAULT_PRN=%printername%"

I want the script to pick up the 'DEFAULT_PRN' attribute from 'INFO' and set it as the default printer.

Basically i need a function which locates to the 'info' attribute in AD and picks up what the 'DEFAULT_PRN' attribute is equal too.

Any help is greatly appreciated.

Thank you \:\)


AllenAdministrator
(KiX Supporter)
2016-06-21 11:31 PM
Re: Selecting Default Printer

Start with this function...

GetADUserProperties() -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=194576#Post194576

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1

Something like:

 Code:
$User=getaduserproperties() 
? $user.info

;paste function here


Glenn BarnasAdministrator
(KiX Supporter)
2016-06-22 12:39 PM
Re: Selecting Default Printer

Allen's example will provide the entire Notes field. You'll need to parse that as well to locate the line containing the printer definition. Something like
 Code:
If InStr($User.info, 'DEFAULT_PRN")
  $Tmp = Split($User.info, 'DEFAULT_PRN=')[1]    ; return all text following "DEFAULT_PRN"
  ; depending on the data structure, you may need to continue parsing to 
  ; remove any data that follows. I'd delimit the end of the printer as an example..
  $DEFAULTP = Split($Tmp, ';')[0]  ; take everything prior to the ";" as the printer name
Else
  $DEFAULTP=$SYSDEFAULTP
EndIf
Just FYI, my login script supports per-user default printers defined in the configuration file - no coding needed. It also has a local %DEFAULT% environment var to assign a LOCAL printer (not mapped by the script) as the default. See my web site for details and the full user manual.

Glenn