|
|
|
| 11 December 2002 | MakePathsFromADlocation() |
| Author | Howard 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. |
| Syntax | MakePathsFromADlocation ($Domain, $Account) |
| Parameters | |
| Remarks | This function is called to build various paths that leverage the AD OU hierachy of where the account resides. |
| Returns | Array |
| Dependencies | TranslateName() |
| 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 -
|
|
|
|