#98453 - 2003-02-17 03:57 AM
(hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I am working on providing a more robust and usable Win32Admin.DLL. The new compiler being used permits me to return an array of hashes. I have a working VBS script but can't get it work in KiXtart 4.20rc2.
I am looking for some more definitive answer if I am just a numbskull or if some COM enhancement should be requested.
There has been some confusion with the VBS script. You have to substitute a valid NT computer name in for "computername" or you will get an error (RPC Server is unavailable. at Win32Admin2.ctrl line 20).
Working VBS code: code:
Set obj = CreateObject("Win32Admin2") A = obj.GrpEnumMembers("computername", "local", obj.GetLocalAdminGrp()) For Each hash In A For Each key In hash.keys() MsgBox "Hash{" & key & "} = " & hash.get(key) Next Next
KiX code: code:
break ON $Win32Admin = createobject("Win32Admin2") $Members = $Win32Admin.GrpEnumMembers(@wksta, "local", $Win32Admin.GetLocalAdminGrp())
for each $hash in $Members for each $key in $hash.keys ? $key next next
I assume that "keys" method just doesn't work from KiXtart. Is there a way to get around this issue or should there be a request made for new functionality?
I can send the DLL to anyone that wants to test this scenario. [ 28. February 2003, 21:03: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#98455 - 2003-02-17 01:18 PM
Re: (hash) COM using Win32Admin
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
My guess would be that the for..each.. intrinsics do not work the same way.
In KiXtart my guess is that an internal copy of the array or object is created and the for..each.. works on this. Check out the following code:
code:
Dim $a[10] For $i = 0 to 9 $a[$i]=chr($i+65) Next
For Each $s in $a "Data=" $s ? Redim Preserve $a[5] Next
This code prints all elements originally created in $a, despite the redim.
Perhaps the ".keys" method returns each key, each time it is called? Or does it simply return nothing?
If it returns a single key for each iteration, perhaps ypu can get away with:
code:
$sKey=hash.keys While $sKey $sKey=hash.keys Loop
If this is not the case, perhaps you can extend the object and add ".reset" and ".nextkey" methods and work off an internal pointer?
|
|
Top
|
|
|
|
#98456 - 2003-02-17 04:06 PM
Re: (hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
KiXtart is trapping the use of the "keys" method. Ruud is investigating.
I have place the test DLL on my web site for those of you that may wish to test this. Jens, Run the test VBS script to see the benefit of using the array of dictionary objects (array of hashes) as the type of data returned.
My thought is that if it works in VBS it should work in KiXtart.
DLL link: http://mywebpages.comcast.net/habullock/Win32Admin2.dll.txt
|
|
Top
|
|
|
|
#98457 - 2003-02-17 04:09 PM
Re: (hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Richard, tried: code:
$a = $Members[0].keys ? vartypename( $a)
last night which failed also.
code:
$a = $Members.keys ? "a=" + vartypename( $a)
fails too. [ 17. February 2003, 16:20: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#98459 - 2003-02-17 04:19 PM
Re: (hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Sorry , at least I got the "J" right. A little better than confusing "Richard" and "Howard" ![[Wink]](images/icons/wink.gif) [ 17. February 2003, 16:19: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#98460 - 2003-02-27 06:59 PM
Re: (hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
KiXtart 4.21RC1 contains changes that permit the following code to now work.
Note that this code only works with the test version of Win32Admin2 (link below) . The purpose is to show a demo of how data will be returned in many of the functions when the next build of the DLL is released. I would like to hear what you think of data in this format (hash) vs. interleaved arrays.
DLL link: http://mywebpages.comcast.net/habullock/Win32Admin2.dll.txt
code:
break ON $Win32Admin = createobject("Win32Admin2") $Members = $Win32Admin.GrpEnumMembers(@wksta, "local", $Win32Admin.GetLocalAdminGrp())
for each $hash in $Members for each $key in $hash.keys ? $key + " " + $hash.get($key) next next
[ 27. February 2003, 22:25: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#98461 - 2003-02-27 07:08 PM
Re: (hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
For those of you that want to know what sidusage is.
1 => 'SidTypeUser', 2 => 'SidTypeGroup', 3 => 'SidTypeDomain', 4 => 'SidTypeAlias', 5 => 'SidTypeWellKnownGroup', 6 => 'SidTypeDeletedAccount', 7 => 'SidTypeInvalid', 8 => 'SidTypeUnknown', 9 => 'SidTypeComputer'
|
|
Top
|
|
|
|
#98464 - 2003-02-28 01:25 PM
Re: (hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I also have an updated program from ActiveState that will FIX the DLL so that This will work with older versions of KiXtart as well. I will be rebuilding the test DLL later today to verify what version of KiXtart will be supported. I am hoping that 4.02 will work.
As far as the HASH support in KiXtart goes, There is no native data structure such as a hash in KiXtart. What we are working with is a structure that is being interpreted as a VB script "Dictionary Object" or associative array. I believe that support for this actually resides in the VB script libraries.
In any case, this is very exciting to me and I think it will provide a more robust way to return data from my DLL.
I can return a group of users with individual account properties in such a way that you could reference which ever property you desire without wading through a current flat array structure.
|
|
Top
|
|
|
|
#98465 - 2003-02-28 09:09 PM
Re: (hash) COM using Win32Admin
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
The new build of the ActiveState tool that builds my Win32Admin.DLL permits Kix versions 4.02, 4.10, 4.11, 4.12, and 4.20 to accept HASH (vb dictionary objects) from my DLL.
The test DLL listed in this thread has been updated.
My plan is to provide a significant re-write that will provide more functionality and better data being returned. Time frame: 6 weeks. [ 28. February 2003, 21:30: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 657 anonymous users online.
|
|
|