Page 1 of 1 1
Topic Options
#98453 - 2003-02-17 03:57 AM (hash) COM using Win32Admin
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98454 - 2003-02-18 12:46 AM Re: (hash) COM using Win32Admin
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Howard,

well, associative Arrays or Hashes ... mmm
Seems to me that the most success promising way would be to return that array as a an array of arrays ($Members[n][n]) or maybe I did get that completely wrong ?

The reason why this won't function is the lack of Kix native support for that kind of arrays as far as I can say (not knowing exactly what I am talking about;) )

Hey well, If you need a beta tester or just a hunchback assistant email the stuff to me and I will have a look

J.
_________________________



Top
#98455 - 2003-02-17 01:18 PM Re: (hash) COM using Win32Admin
Richard H. Administrator Offline
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 Offline
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
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98457 - 2003-02-17 04:09 PM Re: (hash) COM using Win32Admin
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98458 - 2003-02-17 04:10 PM Re: (hash) COM using Win32Admin
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Me Jochen , Jens is Seal [Razz]

Will Dl anyway (Array of hashes is quite new for me as my experiences with languages supporting that aren't too good and I ma willing to learn something new every day)

Jochen
_________________________



Top
#98459 - 2003-02-17 04:19 PM Re: (hash) COM using Win32Admin
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Sorry [Embarrassed] , at least I got the "J" right. A little better than confusing "Richard" and "Howard" [Wink]

[ 17. February 2003, 16:19: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98460 - 2003-02-27 06:59 PM Re: (hash) COM using Win32Admin
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98461 - 2003-02-27 07:08 PM Re: (hash) COM using Win32Admin
Howard Bullock Offline
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'
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98462 - 2003-02-27 10:31 PM Re: (hash) COM using Win32Admin
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
The sample code worked for me Howard.
Top
#98463 - 2003-02-28 10:14 AM Re: (hash) COM using Win32Admin
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Nice !

but that doesn't imply that Hashes are now supported !?
It was 'only' an enhancement of the 'COM Interface , no ?
_________________________



Top
#98464 - 2003-02-28 01:25 PM Re: (hash) COM using Win32Admin
Howard Bullock Offline
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98465 - 2003-02-28 09:09 PM Re: (hash) COM using Win32Admin
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#98466 - 2003-02-28 10:20 PM Re: (hash) COM using Win32Admin
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hey...That's good news Howard.

Hopefully it will be a very handy .DLL when you're all done with it.

Looking forward to possibly using it in the future.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.072 seconds in which 0.033 seconds were spent on a total of 11 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org