Wayne Miller
(Fresh Scripter)
2005-03-16 10:32 PM
In Container

I am trying to determine what OU a computer is in.

using the UDF

Call "Incontainer.udf"

Code:
   $rc = InContainer("OU=ComputerName,OU=Site,OU=BU,DC=us,DC=guess,DC=com", "Computer")
? $rc



I am getting the error code

Script error : expected expression !
$Name2 = TranslateName (3, "", 3, $Name1, 1)

Any Idea? I have both the InContainer.udf and TranslateName.udf functions in the directory as the script.


Les
(KiX Master)
2005-03-16 10:36 PM
Re: In Container

The UDF returns an array and KiX cannot take an array directed to the console.
Try:
$rc = InContainer("OU=ComputerName,OU=Site,OU=BU,DC=us,DC=guess,DC=com", "Computer")[0]


Wayne Miller
(Fresh Scripter)
2005-03-16 10:51 PM
Re: In Container

I still got the same error. It seems to be coming from the translate code. If you want I can upload it but I took it directly off the udf library.


maciep
(Korg Regular)
2005-03-16 10:56 PM
Re: In Container

did you read the dependencies of the udf, you need the TranslateName() udf as well

Quote:


;DEPENDENCIES OS: Active Directory aware client
; Other Functions: TranslateName()





Wayne Miller
(Fresh Scripter)
2005-03-16 11:25 PM
Re: In Container

Thanks. I assumed that the incontainer was calling translatename.

However I am now getting object is Not a member of this container or a chile of this container. However I know it is.

Is it possible I am missing something in the syntax.

Code:
 ;$rc = InContainer("OU=ComputerName,OU=Site,OU=BU,DC=us,DC=guess,DC=com", "Computer") 



Les
(KiX Master)
2005-03-17 12:15 AM
Re: In Container

How can we know if you have the syntax right if you obfuscate the DN with bogus example? What is "OU=ComputerName" supposed to represent? Do you really have a computer in an OU that that is called "computername"?

Les
(KiX Master)
2005-03-17 01:41 AM
Re: In Container

WHat I originally said about the UDF returning an array still stands. You cannot direct $rc to the console.

Wayne Miller
(Fresh Scripter)
2005-03-17 10:27 PM
Re: In Container

When exectued the following appears
object is NOT a member of this container or a child of this container

However I have verified that computer lta0210896a exist in
an ou within the NTX ou

Am I listing the computer name correctly?
Code:

Call "translatename.udf"
Call "Incontainer.udf"

$rc= InContainer("OU=@WKSTA,OU=NTX,DC=us,DC=dseg,DC=com","Computer")

Select
Case $rc[0]=1 ? "object is a member of the specified container."
Case $rc[0]=2 ? "object is a member of a child container lower in the hierarchy."
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



Les
(KiX Master)
2005-03-17 10:38 PM
Re: In Container

You are using the UDF wrong. @WKSTA is not an OU is it? I mean, you don't have an OU named after every computer do you?
$rc= InContainer("OU=NTX,DC=us,DC=dseg,DC=com","Computer")


Howard Bullock
(KiX Supporter)
2005-03-17 10:40 PM
Re: In Container

If you post your code that is failing, I would be happy to review it. Be sure to use the Instant UBB code (Code) to properly format the posted code.

Les
(KiX Master)
2005-03-17 10:47 PM
Re: In Container

The computer name is implied. You should not pass it as a parm. If you need a version of Howard's UDF that takes the computername as a 3rd parm, I modified the UDF to work in an admin script.

Wayne Miller
(Fresh Scripter)
2005-03-18 12:15 AM
Re: In Container

Thanks Les. Thats It I didn't read the udf paramaters properly.

Jaap_Lelie
(Fresh Scripter)
2005-04-04 12:30 PM
Re: In Container

Dazzling...

Simple question, I hope. I've browsed the board and all examples I see start from the principle that I ask "Is this user in OU xxx?" and I get a Yes or a No.

Is there a way to just get a string returned that represents the OU the user is in? like a sort of GetOU("%USERNAME%") so to speak?

My thanks,
Jaap.


Les
(KiX Master)
2005-04-04 02:59 PM
Re: In Container

No, but the TranslateName() UDF with a simple Split() or two would do it. It has been discussed before.