scripting@wanadoo.nl




MakePathsFromADlocation()

http://www.scriptlogic.com/kixtart/FunctionLibrary_FunctionList.aspx


actual FunctionLibrary list on 'Scriptlogic' site printer-friendly mirror of UDF topic on 'scripting@wanadoo.nl' site close
11 December 2002 MakePathsFromADlocation()
AuthorHoward A. Bullock
Action Use TranslateName() to return the Conical Name of an account from the ActiveDirectory. The concical name is then split up and the parts are used to build a series of directory paths that are stored in an array. Certain characters that are invalid in in directory names are removed from the conical name and are not included in the final path. This array of paths can be used to execute subscripts for specific collections of users or computers based on domain and OU hierachy.
SyntaxMakePathsFromADlocation ($Domain, $Account) 
Parameters
  • $Domain (Required / String) NetBIOS domain name
  • $Account (Required / String) User or Computer account 
  • RemarksThis function is called to build various paths that leverage the AD OU hierachy of where the account resides. 
    ReturnsArray 
    DependenciesTranslateName() 
    Examples
    $Paths = MakePathsFromADlocation(@LDomain, @UserID)
    $Paths = MakePathsFromADlocation(@Domain, @wksta + '$$')
    
     
    Source
    FUNCTION MakePathsFromADlocation ($domain, $account)
      DIM $conicalname, $char, $piece, $path[0]
      ;retrieve conical name from AD's global catalog
      $conicalname = translatename (3, "", 3, $domain + "\" + $account, 2)
      IF $conicalname[1] = 0
        ;Remove characters that are invalid in directory names.
        $chars = '\/', '\', ':', '*', '?', '"', '<', '>', '|'
        FOR EACH $char IN $chars
          ; JOIN requires KiXtart 4.11 or higher.
          ;$Conicalname[0] = join(split($Conicalname[0], $char),"")
          ;
          ;Start KiXtart 4.02 compatible code for JOIN replacement
          DIM $temp
          FOR EACH $piece IN Split($conicalname[0], $char)
            $temp = $temp + $piece
          NEXT
          $conicalname[0] = $temp
          ;End KiXtart 4.02 compatible code for JOIN replacement
        NEXT
        ;
        ; Build and array of directory paths
        ; Stripping off the domain and the (computer or user)
        ; split full name into pieces (directories names)
        ;
        $piece = Split($conicalname[0], "/")
        REDIM $path[UBound($piece)-1]
        $path[0] = "netlogon";
        FOR $i=1 TO UBound($path)
          $path[$i] = $path[$i-1] + "\" + $piece[$i]
        NEXT
      ELSE
        $path =""
        writelog('Error: MakePathsFromADlocation ($Domain, $Account)')
        writelog('Error: '+$conicalname[1]+" "+$conicalname[2]+" (TranslateName)")
      ENDIF
      $makepathsfromadlocation = $path
    ENDFUNCTION ; - MakePathsFromADlocation -
     
      original source of UDF topic. show actual FunctionLibrary list on Scriptlogic site close top
              printer-friendly mirror of UDF topic on scripting@wanadoo.nl site  




    Copyright © 2003 www.scriptlogic.com & scripting@wanadoo.nl - last updated on 20 May 2003


    Site Meter