Page 2 of 2 <12
Topic Options
#172555 - 2007-01-08 11:53 PM Re: How to find an OU? [Re: Chris S.]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Why not the enumOUs routine like what I use for computers in McAfee Manager. Look for UO's containing user accounts and populate a combobox with the hits

To move a user you don't need the source OU, just the destination.



Code:
break on

$l="LDAP://"+@domain+"/"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
$ou = EnumOUs($l, 'user')
for each $item in split($ou,'|')
	? $item
next


Function EnumOUs($LDAP, $Filter)
     dim $aFilter[0], $pos,  $objOU, $i, $j

     if $Filter <> 'user'
          $Filter = 'computer'
          endif
     $objOU = GetObject($LDAP)
     if VarTypeName($objOU)='Object'
          $aFilter[0] = $Filter
          $objOU.Filter = $aFilter
          for each $item in $objOU
              ; $PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0)     ;for progress bar only
               if $item.class = $Filter
                    $i = $LDAP
                    endif
               next
          $aFilter[0] = "organizationalUnit"
          $objOU.Filter = $aFilter
          for each $item in $objOU
              ; $PBar1.Value = iif($PBar1.Value < $PBar1.Max,$PBar1.Value + 1,0)     ;for progress bar only
               $Name = $item.Name
               $pos = instrrev($LDAP,"/")
               $DN = Left($LDAP,$pos) + $Name + ", " + substr($LDAP, $pos+1)
               $j = EnumOUs($DN, $Filter)
               if $j
                    $i = iif($i,$i +"|"+ $j,$j)
                    endif
               next
          endif
      $EnumOUs = $i
     Endfunction
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#172556 - 2007-01-09 01:34 AM Re: How to find an OU? [Re: Arend_]
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Originally Posted By: apronk
Old thread I know, but I find myself searching for the same thing here.
Even though I'd have to agree with Howard on the best alternative solution, make a group in the OU you're trying to find. However I'm making a script that will be deployed on about 20 networks. I don't wanna make groups on every network. Basically TranslateName has the shortcoming of not being able to find OU's.


I just might nominate you for a necromancer award, for resurecting the dead...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.197 seconds in which 0.172 seconds were spent on a total of 14 queries. Zlib compression enabled.

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