Break ON
$=SetOption("Explicit","ON")
Dim $aAttributes,$sADsPath,$strFilter
Dim $aUsers,$iIndex,$sPath,$aOUs,$sElement,$sDSN
$aAttributes = "samAccountName", "AdsPath"
$sADsPath = "LDAP://"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
$strFilter = "(&(objectClass=User)(objectClass=person)(Name=*))"
$aUsers = fnLDAPQuery($aAttributes,$sADsPath,$strFilter,"Name")
; Ensuring Directories exist
For $iIndex=0 To UBound($aUsers)
$sDSN=$aUsers[$iIndex,1]
; First drop the providor and CN information
$sDSN=SubStr($sDSN,InStr($sDSN,",OU=")+4)
; Now drop the domain information
$sDSN=SubStr($sDSN,1,InStr($sDSN,",DC=")-1)
; Finally, split the OU parts out
$aOUs=Split($sDSN,",OU=")
; Now create the path
$sPath=""
For Each $sElement in $aOUs
$sPath="\"+$sElement+$sPath
Next
"Path for "+$aUsers[$iIndex,0]+"="+$sPath ?
Next