Did some Googling and found the script below. It is VBS and I tried to translate it to kix but failed. As a VBS script it works just fine. I have to admit that I tried to translate it just once and that I'm not so familiar with VBS but I guess it can be translated to kix by someone who is more familiar with VBS.

You could use the good old ComNetView() udf to get all computers, get their OU and filter on the OU you need.

Source: http://www.wisesoft.co.uk/scripts/vbscript_find_computer's_organizational_unit.aspx

 Code:
Option Explicit
Dim objNetwork
Dim computerName
Dim ou

' Get the computerName of PC
Set objNetwork = CreateObject("Wscript.Network")
computerName = objNetwork.ComputerName

' Call function to find OU from computer name
ou = getOUByComputerName(computerName)

WScript.echo ou


Function getOUByComputerName(byval computerName)
	' *** Function to find ou/container of computer object from computer name ***
		
	Dim namingContext, ldapFilter, ou
	Dim cn, cmd, rs
	Dim objRootDSE
		
	' Bind to the RootDSE to get the default naming context for
	' the domain.  e.g. dc=wisesoft,dc=co,dc=uk
	Set objRootDSE = GetObject("LDAP://RootDSE")
	namingContext = objRootDSE.Get("defaultNamingContext")
	Set objRootDSE = Nothing
	
	' Construct an ldap filter to search for a computer object
	' anywhere in the domain with a name of the value specified.
	ldapFilter = "<LDAP://" & namingContext & _
	">;(&(objectCategory=Computer)(name=" & computerName & "))" & _
	";distinguishedName;subtree"
	
	' Standard ADO code to query database
	Set cn = CreateObject("ADODB.Connection")
	Set cmd = CreateObject("ADODB.Command")
	
	cn.open "Provider=ADsDSOObject;"
	cmd.activeconnection = cn
	cmd.commandtext = ldapFilter
		
	Set rs = cmd.execute
	
	If rs.eof <> True And rs.bof <> True Then
		ou = rs(0)
		' Convert distinguished name into OU.
		' e.g. cn=CLIENT01,OU=WiseSoft_Computers,dc=wisesoft,dc=co,dc=uk
		' to: OU=WiseSoft_Computers,dc=wisesoft,dc=co,dc=uk
		ou = Mid(ou, InStr(ou, ",") + 1, Len(ou) - InStr(ou, ","))
		getOUByComputerName = ou
		
	End If
	
	rs.close
	cn.close
	
End Function
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.