BrianTX
(Korg Regular)
2002-06-24 10:35 PM
Properties of an object using ADSI.

I was fiddling with this and came up with two functions that return arrays: one for the properties associated with an ADSI object, and the other for the values associated with the properties given. Here is the code.

code:
$domain = "domainname"
$ads = GetObject("WinNT://$domain")

Function GetProperties($adsiobject)
$adsiobject.GetInfo
$countprop = VAL($adsiobject.propertycount)-1
If $countprop < 0
Exit 1
ENDIF
DIM $adsiprop[$countprop]
For $i = 0 to $countprop
$adsiprop[$i] = $adsiobject.Next().name
Next
$GetProperties = $adsiprop
EndFunction


Function GetValues($proparray,$adsiobject)
If NOT Vartype($proparray) & 8192
Exit 1
Endif
$ba = UBOUND($proparray)
DIM $propval[$ba]
For $i = 0 to $ba
$prop=$proparray[$i]
$rc = EXECUTE("$$PropVal[$$i]=$$adsiobject.$prop")
If @error
Exit 1
Endif
Next
$GetValues = $propval
EndFunction




$ok = GetProperties($ads)
$bk = GetValues($ok,$ads)
For $i = 0 to UBOUND($ok)
$ok[$i] ?
$bk[$i] ?
Next

Anyone have thoughts on this? Useful? Worthless?

Brian

[ 24 June 2002, 22:39: Message edited by: BrianTX ]


Howard Bullock
(KiX Supporter)
2002-06-24 10:54 PM
Re: Properties of an object using ADSI.

Is this a little like http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=13;t=000139 4th post?

BrianTX
(Korg Regular)
2002-06-24 10:59 PM
Re: Properties of an object using ADSI.

Yeah.. it's similar, although I took a different approach. I'm still fiddling with this stuff, though. I suppose one difference is that your script enumerates optional properties.. I'm not sure mine does.

Brian

[ 24 June 2002, 23:01: Message edited by: BrianTX ]


BrianTX
(Korg Regular)
2002-06-24 11:43 PM
Re: Properties of an object using ADSI.

I forgot about the adsi object viewer (adsvw.exe) in the Microsoft Platform SDK.. it works pretty well.

Brian