Registered: 2007-03-13
Posts: 2
Loc: Utrecht, The Netherlands
Hello
I am now busy to make scripts with kixtart. I it quite good, only that I now have a problem with the coupling of printers in my departments in my company.
The company has been classified in deparments and each department has his own printer. In my script I give that each department must have his own printer.
When I do that I get a error. My script is:
Code:
; Printers toewijzen aan gebruikers per afdeling
; Printers voor Afdeling Inkoop
IF InOU("Afdeling Inkoop", 1)
IF AddPrinterConnection ("\\176server\Afdeling Inkoop") = 0
SetDefaultPrinter ("\\176server\Afdeling Inkoop")
IF InOU("Afdeling Inkoop", 1)
IF AddPrinterConnection ("\\176server\Secretariat") = 0
EndIf
; Printers voor Afdeling Verkoop
IF InOU("Afdeling Verkoop", 1)
IF AddPrinterConnection ("\\176server\Afdeling Verkoop") = 0
SetDefaultPrinter ("\\176server\Afdeling Verkoop")
IF InOU("Afdeling Inkoop", 1)
IF AddPrinterConnection ("\\176server\Hoofd Administratie") = 0
EndIf
What do I wrong, what must I do so that it well does. I hope that you my can help.
Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
We have two groups for each printer. One is for the users that should get the printer as default and one for the users that should get the printer as a extra printer. On each group we do an if - else - endif.
Something like this.
Code:
;printer1
If InGroup("printer1-defgrp")
AddPrinterConnection ("\\server\printer1") = 0
SetDefaultPrinter ("\\server\printer1")
EndIf
If InGroup("printer1-extgrp")
AddPrinterConnection ("\\server\printer1") = 0
EndIf
;
;printer2
If InGroup("printer2-defgrp")
AddPrinterConnection ("\\server\printer2") = 0
SetDefaultPrinter ("\\server\printer2")
EndIf
If InGroup("printer2-extgrp")
AddPrinterConnection ("\\server\printer2") = 0
EndIf
The scripts get written automatically by and admin script that runs every two hours and checks the group membership of all users. First we collect all users from AD and then we use the UserGroups UDF to get the group membership for each user. UserGroups() - returns all groups of a given user
Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
You need to match each IF with an ENDIF - the simplest way is via indents (as you do) AND adding a comment to the EndIf so you know "who it belongs to".
Code:
IF InOU("FirstOU")
Do this, and that, and some other things..
ENDIF ; in "FirstOU"
I do this with long blocks of IF/Else/Endif, but if you aren't used to it, or are debugging, it makes sense to add the comments to EVERY If/EndIf pair.
Don't forget, "InOU" is not a Kix function - if you want to check OU membership, you need to write or download a UDF and include it in your code.
Glenn
_________________________ Actually I am a Rocket Scientist!