|
|
|||||||
Is it possible to use IF on OU, like we use IF ingroup ? |
||||||||
|
|
|||||||
Welcome to the board. You can't use ingroup to check on OU membership. However there is a UDF here that can do this task for you. InContainer() - Determines if the current account or computer is in a container |
||||||||
|
|
|||||||
Thank you for faaast answaer Will the syntax be : 'IF INCONTAINER ("OU")' TR |
||||||||
|
|
|||||||
The syntax is listed in the commented section (see examples part). Please also read the dependencies section (just above the examples part) cause it requires an extra UDF called TranslateName() and AD aware clients. |
||||||||
|
|
|||||||
I'm sorry, I'm a rookie on kix, what would be the right syntax if I want to check a users OU membership syntax ? |
||||||||
|
|
|||||||
Something like this should do. You should change this part OU=test,OU=9826,OU=NCS,OU=Machines,DC=us,DC=tycoelectronics,DC=com to match your situation. The user to query is now set to the user the script runs on by the first line of code below. Code:
|
||||||||
|
|
|||||||
Jeez, all this just to check if a user is member of an OU ??? |
||||||||
|
|
|||||||
Two functions are included in the code above. One to check if the user is a member and one to convert the name. |
||||||||
|
|
|||||||
Quote: Yes, KiXtart doesn't support the features natively, so it can get a little complicated. However, for your needs the following might provide all the information that you require: Code: $=SetOption("WrapAtEOL","ON") |
||||||||
|
|
|||||||
I was going to use a check on OU, for mapping printers for users in that spesific OU. ps. I am getting the error code 2 when using setdefaultprinter, any idea ? This is my script : IF INGROUP ("Stamsund") If AddPrinterConnection ("\\aks01\hp4200-stamsund") = 0 ? "Added printer connection...." endif SetDefaultPrinter("\\aks01\hp4200-stamsund") ? "Set default printer to HP LaserJet 4...." |
||||||||
|
|
|||||||
Is the printer AND the share name the same? |
||||||||
|
|
|||||||
You should use Addprinterconnection() first |
||||||||
|
|
|||||||
yepp. I typed wrong. AddPrinterConnection is first. My problem with that one was wrong printername, when using SetPrinterDefault.. |
||||||||
|
|
|||||||
But I really need som good advice for a short script for checking before mapping a printer, with user in a OU, not a group... Richard H. : Can I use you script for this purpose ? |
||||||||
|
|
|||||||
Is there no good tips for using IF with OU check for users, when mapping printers ? |
||||||||
|
|
|||||||
Quote: Yes. Have you tried it? You should see your user path displayed. Now you can use something like "InStr()" to check is you are in an OU. Here is an example which checks if I'm in the IT staff OU: Code: $oADInfo = CreateObject("ADSystemInfo") |
||||||||
|
|
|||||||
I think you have already been given the best solution. Use InContainer(). As discussed in a previous thread InContainer always calls TranslateNAme() which can add substatial overhead to the script. A cleaner solution is to use TranslateName() to get the user's OU and then use a modified Incontainer() that only compares strings representations of the OU's DN. I will post the code after I get to work. |
||||||||
|
|
|||||||
Howard, What's the issue with using the scriptlet I've just posted? I'd planned on using it myself in various places so if there is a potential problem I'd like to know about it. |
||||||||
|
|
|||||||
Looks good Richard. I was rushing around and did not spend sufficient time reading your post. You solution is elegantly simple and directly applicable to a single user logging on which satisfies the request. I think that my solution is more flexible/powerful (shameless plug) from an admin script perspective. Your solution only seems to identify that the user is somewhere in the OU tree. My solution determine if you are in the OU or a child. |
||||||||
|
|
|||||||
Hi All! Good to be a member of the board, i've been looking through this forum alot, thanks to everyone for the help so far. I am hoping to do the same thing Tryvge was trying to do in his last post (with InContainer). For example if a user is in a certain OU map this printer, drive etc, if a user is in this other OU do this, that etc.. Was just wondering if you had that sample code you mentioned by any chance please? Quote: Just if you have it handy thats all, Thanks a mill |
||||||||
|
|
|||||||
With regard to the above, thanks anyway lads, i've used Richard H's script instead which did the job. Thanks a million |