|
|
|||||||
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. Thanks! |
||||||||
|
|
|||||||
Do you have a function defined called "InOU"? Can you post the code, or a reference to it if it's already on the BBS? Also, you are missing SIX EndIf statements.. Glenn |
||||||||
|
|
|||||||
Okey, what must I do then? Where must I set SIX EndIf statements ?? |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
InOU() Sounds a bit like InContainer() - Determines if the current account or computer is in a container |
||||||||
|
|
|||||||
Don't think I posted this (yet)- this could also work - right from the example in the header. Glenn
|
||||||||
|
|
|||||||
Maybe it is this one? InOU() - Check user/computer OU from Active Directory |