If anyone can help me with my problem I would be over the moon, the problem is Say I want to map a drive using group names I would use the following IF INGROUP("Group name") but say I want to use organisation units instead of Groups is that possible and if so want is the code
Hi thanks for the reply. I have seen that before but I have no idea how to use it I was hoping some one could show me how too. Even then I’m not sure it will do what I want Cheers
#136632 - 2005-03-3010:19 AMRe: OU instead of Groups
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
You need to be running KiXtart 4.x hopefully 4.22 or 4.23 to run UDF code. KiXtart 3.x can not run UDF code.
There is an example of using it in the notes of the UDF which is like this.
Code:
Dim $rc $rc = InContainer ("OU=test,OU=9826,OU=NCS,OU=Machines,DC=us,DC=tycoelectronics,DC=com", "Computer") Select case $rc[0]=1 ? "object is a member of the specified container. Run code you want to run" case $rc[0]=2 ? "object is a member of a child container lower in the hierarchy. Run code you want to run" case $rc[0]=0 ? "object is NOT a member of this container or a child of this container." case $rc[0]=-1 ? "InContainer() Error - Invalid input for $NameType " case $rc[0]=-2 ? "TranslateName() Error" case 1 ? "Unknown return code" EndSelect
My Kix programming skills are far from perfect all i need to do is Map drives and create printer connections via the OU i have created the code using groups but my IT director will only use Kix if we can use OUs instead of groups for these functions. i thought it would be simple like bellow
Code:
break on
If InContainer('ou=Users,ou=Information Technology,OU=Dublin,dc=lab,dc=iconcr,dc=com','User')[0] ? 'T: (\\shortts\DATA)' Use T: '\\shortts\DATA' EndIf
But obviously I’m wrong and it is more complex, Sorry to be a pain but I would love to get this working at the moment there using Bach files Mate
Above I have the bath of the distinguished name of the user location how would the code fit
#136635 - 2005-03-3012:23 PMRe: OU instead of Groups
AnonymousAnonymous
Unregistered
I have tryed what you have sugested and i have put in
Code:
if inContainer("ou=Users,ou=Information Technology,OU=Dublin,dc=lab,dc=iconcr,dc=com","User")
USE K: "\\shortts\DATA\Department\SO-Storage-IR"
endif
but im getting ERROR: expected expresion could it be my distinguished name and if so what the best way to find out or test if it the right distinguished name im pritty sure it is but i could be missing smothing Stupid
so, I think you are actually lacking the udf from your script itself. right?
add the code of incontainer (everything from function keyword to endfunction) to your script. does not matter what the place is. many of us even use call or include to not directly place it in the script file.
but plug that code in and try again. and, remember, it's udf, do not alter the code anyhow or anything. it's a self-contained "subProgram", just add it in and forget that it's there.
#136641 - 2005-03-3102:54 AMRe: OU instead of Groups
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
Okay, don't forget you need the TranslateName UDF and the InContainer UDF either all in the same script or available via a call to them.
Code:
Dim $UsersOU $UsersOU = InContainer('ou=Users,ou=Information Technology,OU=Dublin,dc=lab,dc=iconcr,dc=com','User') If $UsersOU[0]=1 ? 'T: (\\shortts\DATA)' Use T: '\\shortts\DATA' Else ? 'User was not found in the Users, Information Technology OU or some other error' EndIf
Thanks for your help sorry for the late reply but i based in Ireland and left work early yesterday... the pressure LoL
Thanks for your time everyone ill have to do a little research on TranslateName UDF and the InContainer UDF beacuse i really havent got a clue about them what they do and how to implement them, but i will look into it but any advice about it would be appreciated...
Im so confused there is a lot in this. I think I bit off more than I can chew can you have a look at the script bellow and advice me what im doing wrong or what im leaving out… sorry to bother you but im just not that good at kix Code:
**************************************************************************************************** **************************************************************************************************** ; InContainer() - Determines if the current account or computer is in a container **************************************************************************************************** ****************************************************************************************************
Function InContainer ("OU=Users,OU=Information Technology,OU=Dublin,DC=lab,DC=iconcr,DC=com", "Users") Dim $Container, $CurrentContainer, $NameType, $Name1, $Name2
select case $NameType = "Computer" $Name1 = "@Domain\@wksta$" case $NameType = "User" $Name1 = "@LDomain\@UserID" case 1 $Name1 = "" endselect
if $Name1 <> "" $Name2 = TranslateName (3, "", 3, $Name1, 1) if $Name2[1] = 0 $CurrentContainer = substr($Name2[0], instr($Name2[0], ",")+1) select case $rc[0]=1 ? "object is a member of the specified container." case $CurrentContainer=$Container $InContainer = 1, $Name2[1], $Name2[2] case instr($Name2[0], $Container) $InContainer = 2, $Name2[1], $Name2[2] case 1 $InContainer = 0, $Name2[1], $Name2[2] endselect else $InContainer = -2, $Name2[1], $Name2[2] endif else $InContainer = -1, 0, "" endif EndFunction
Dim $UsersOU $UsersOU = InContainer('OU=Users,OU=Information Technology,OU=Dublin,DC=lab,DC=iconcr,DC=com','User') If $UsersOU[0]=1 ? 'T: (\\shortts\DATA)' Use T: '\\shortts\DATA' Else ? 'User was not found in the Users, Information Technology OU or some other error' EndIf
Are you getting an error or is it just saying that user is not in that OU? Does the user account physically live in the 'Users' OU or is it in a SubOU? What does InContainer() actually return?
Code:
Dim $UsersOU $UsersOU = InContainer('OU=Users,OU=Information Technology,OU=Dublin,DC=lab,DC=iconcr,DC=com','User') ? $UsersOU[0] If $UsersOU[0]=1 ? 'T: (\\shortts\DATA)' Use T: '\\shortts\DATA' Else ? 'User was not found in the Users, Information Technology OU or some other error' EndIf
#136647 - 2005-03-3109:35 PMRe: OU instead of Groups
NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11631
Loc: CA
Nice catch there Howard.
Trooper - please don't modify any UDF until you've become more familiar with KiXtart and understand the implcations of your modifications. UDF are designed to be used sort of like a black-box solution. You call them and provide data for them, but don't modify them.
Please copy this code below into WORDPAD, then copy again from WORDPAD into either Notepad or some other ASCII editor and save the file as CONTAINER.KIX then call it from DOS console like this so you can view the returned data. Then report back what you saw on screen. Please use KiXtart 4.22 or 4.23
not sure if your supplied example is exactly as you are using it, but you need to make sure you comment out the asterisks.. ; ********* ; FUNCTION TranslateName() ; *********
_________________________
John LM Contractor One of the 2 dads