FIND LDAP PATH of COMPUTER OBJECT



Hi

I'm a noob and have been trying to write a code in VBS to find the ldap

path of a computer object in vain..


So far, I have


------
set UserData = CreateObject("ADSystemInfo")
'load string into array
OUArray = Split(Userdata.computername,",")
'loop through array elements
For Each OU in OUArray
'if we found an OU in the array element
If UCase(Left(OU,2))="OU" Then
'trim off the first 3 characters
OUName = Mid(OU,4)
'add to output string
OUList = OUName & vbcrlf
End If
Next
wscript.echo OUList
------


But it doesn't return the OUs properly.
I mean, say if the LDAP path of the computer object is


LDAP://OU=D,OU=C,OU=B,OU=A,DC=XYZ,DC=MI,DC=EDU


then the code above just returns B


and I would like to find the whole path as in


XYS.MI.EDU/A/B/C/D


I could use some help if I may..


& I relle appreciate it..
Thanks so much

.


Loading