Page 1 of 1 1
Topic Options
#135835 - 2005-03-16 10:32 PM In Container
Wayne Miller Offline
Fresh Scripter

Registered: 2002-05-14
Posts: 30
Loc: Dallas, TX
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.

Top
#135836 - 2005-03-16 10:36 PM Re: In Container
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#135837 - 2005-03-16 10:51 PM Re: In Container
Wayne Miller Offline
Fresh Scripter

Registered: 2002-05-14
Posts: 30
Loc: Dallas, TX
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.

Top
#135838 - 2005-03-16 10:56 PM Re: In Container
maciep Offline
Korg Regular
*****

Registered: 2002-06-14
Posts: 947
Loc: Pittsburgh
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()



_________________________
Eric

Top
#135839 - 2005-03-16 11:25 PM Re: In Container
Wayne Miller Offline
Fresh Scripter

Registered: 2002-05-14
Posts: 30
Loc: Dallas, TX
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") 


Top
#135840 - 2005-03-17 12:15 AM Re: In Container
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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"?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#135841 - 2005-03-17 01:41 AM Re: In Container
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
WHat I originally said about the UDF returning an array still stands. You cannot direct $rc to the console.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#135842 - 2005-03-17 10:27 PM Re: In Container
Wayne Miller Offline
Fresh Scripter

Registered: 2002-05-14
Posts: 30
Loc: Dallas, TX
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


Top
#135843 - 2005-03-17 10:38 PM Re: In Container
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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")
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#135844 - 2005-03-17 10:40 PM Re: In Container
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#135845 - 2005-03-17 10:47 PM Re: In Container
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#135846 - 2005-03-18 12:15 AM Re: In Container
Wayne Miller Offline
Fresh Scripter

Registered: 2002-05-14
Posts: 30
Loc: Dallas, TX
Thanks Les. Thats It I didn't read the udf paramaters properly.
Top
#135847 - 2005-04-04 12:30 PM Re: In Container
Jaap_Lelie Offline
Fresh Scripter

Registered: 2005-04-04
Posts: 10
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.

Top
#135848 - 2005-04-04 02:59 PM Re: In Container
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
No, but the TranslateName() UDF with a simple Split() or two would do it. It has been discussed before.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 191 anonymous users online.
Newest Members
thequeen, ameliaryan, shalomsalami, dkdssdk, Vroon
17639 Registered Users

Generated in 0.036 seconds in which 0.011 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org