The UDF works fine - you've got three problems with your script.

First - a pair of problems.. You are not declaring variables, so - every variable you use are automatically declared as a global. You're then using the same variable names inside and outside of the UDF - a problem when they are globals.

Second - you're (correctly) displaying the DN as $Account[0], but you are passing the Array to the function. The array is looking for an account, not an array of data.

Third, in the TranslateName function, you're declaring the variables that are passed as args in the function. That's not correct.

Take a look at these changes, which work fine on my system:

Glenn


$Rc = SetOption('Explicit', 'On')
 
Dim $Account, $Nested, $Groups, $Group
 
 
$Account = TranslateName (3, "", 3, "@LDomain\@userid", 1)
"DN = " + $Account[0] ?
$Nested = 0
$Groups = ListNestedGroups($Account[0],$Nested) 
 
If @ERROR
  'Unexpected error retrieving groups. ' + @ERROR + ' - ' + @SERROR ?
Else
  If UBound($Groups) >= 0
    For Each $Group In $Groups
      ? " Group :"+ $Group 
    Next
  EndIf
EndIf 
 
 
$Account = TranslateName (3, "", 3, "@LDomain\@userid", 1)
"DN = " + $Account[0] ?
 
listnestedgroups($Account[0])
 
Function ListNestedGroups($_Account,Optional $_Nested)
  Dim $_objUser, $_colGroups, $_objGroup, $_Grps, $_NFlag
  Dim $_W, $_Element, $_TempString, $_OD, $_CN, $_ERR
 
  ; init the vars  
  $ListNestedGroups = 0                          ; default return value if errors occur  
  $_Nested = Val($_Nested)                       ; force to numeric value  
  $_NFlag = IIf($_Nested = 1, ' <Nested>', '')   ; set the output message for nested groups  
 
  $_objUser = GetObject($_Account)               ; instantiate the object  
  $_ERR = Val('&' + Right(DecToHex(@ERROR), 4))  ; get last 4 nybbles (2 bytes) of the error code  
  If $_ERR Exit $_ERR EndIf
 
  $_colGroups = $_objUser.Groups                 ; get the collection  
 
  For Each $_objGroup in $_colGroups
 
    $_OD = GetNested($_objGroup)                 ; nested group name  
    $_CN = $_objGroup.CN                         ; parent group name  
 
    ; Write the nested group name (and optional NESTED tag) to the index file  
    If $_OD <> ''
      If InStr($_TempString, $_OD) = 0
         $_TempString = $_TempString + $_OD + $_NFlag + Chr(10)
      EndIf
    EndIf
 
    ; write the parent group name to the index file, unless in nested-only mode  
    If $_Nested < 2
      If InStr($_TempString, $_CN) = 0
         $_TempString = $_TempString + $_CN + Chr(10)
      EndIf
    EndIf
 
  Next
 
  ; enumerate the index and put the value(s) into an array  
  $_Grps = Split(Left($_TempString,Len($_TempString)-1), Chr(10))
 
  ; Return the array of groups, and exit with success  
  $ListNestedGroups = $_Grps
  Exit 0
EndFunction
 
; Sub-Function for returning nested groups  
Function GetNested($objGroup)
  Dim $_colMembers, $_strMember, $_strPath, $_objNestedGroup, $_ERR
  ; init the return value to a null string  
  $GetNested = ''
  ; get the collection  
  $_colMembers = $objGroup.GetEx("memberOf")
  ; enumerate the collection  
  For Each $_strMember in $_colMembers
    $_strPath = "LDAP://" + $_strMember
    $_objNestedGroup = GetObject($_strPath)
    $GetNested = $_objNestedGroup.CN
  Next
  Exit 0
EndFunction
 
Function TranslateName($InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType)
 
   ; Dim $InitType, $BindName, $LookupNameType, $LookupName, $ReturnNameType 
   Dim $NameTranslate, $ReturnName, $Error, $ErrorText
 
   $Error = 0
   $ErrorText = ""
   $ReturnName = ""
   $NameTranslate = CREATEOBJECT ("NameTranslate")
   $Error = @error
   $ErrorText = @serror
   if $Error = 0
      $NameTranslate.Init ($InitType, $BindName)
      $Error = @error
      $ErrorText = @serror
      if $Error = 0
         $NameTranslate.Set ($LookupNameType, $LookupName)
         $Error = @error
         $ErrorText = @serror
         if $Error = 0
            $ReturnName = $NameTranslate.Get($ReturnNameType)
            $Error = @error
            $ErrorText = @serror
         endif
      endif
   endif
   $TranslateName = $ReturnName, $Error, $ErrorText
Endfunction
 
_________________________
Actually I am a Rocket Scientist! \:D