Thanx for your answer Mart. I can´t get the UDF ListNestedGroups to work. I´m just trying to run through it but it fails with a "ERROR : Error in expression: this type of array not supported in expressions.!"
I´ve used another UDF Translatename to get the DN of the current user. What am I doing wrong? Se code below.

 Code:
$_Account = TranslateName (3, "", 3, "@LDomain\@userid", 1)
                ? "DN = " + $_Account[0]
$_Nested = 0
$Groups = ListNestedGroups($_Account,$_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)

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


Edited by lawe009 (2008-11-04 02:50 PM)