Howard Bullock
(KiX Supporter)
2002-10-07 10:14 PM
Win32Admin.DLL for your COMing pleasure

See Win32Admin.DLL for some additional COM functionality.

The script at the web site has a combination of documentation and example code. Let me know what additional functionality you would like added. As it stands now, I will be adding code every few days so that this DLL will provide unparalleled Win32 power for your KiXtart code.

Some sample code...
code:
break ON

; Win32Admin.DLL documentation and example KiXtart code

; All methods set return data or true on success or nothing on failure.
; Also @error is set when an error occurs but does not seem to be reset on success.
; Therefore, checking the function result seems to be the best method of
; determining when an error occurs.
; @Error may not reflect the actual error of methods. Be sure to
; check @serror as it will reflect the correct text of the COM error.

$Win32Admin = createobject("Win32Admin")
if vartypename($Win32Admin) <> "Object"
? "@serror"
endif

$Version = $Win32Admin.Version
if @error <> 0
? "@serror"
endif
? "DLL Version = " + $Version


; Method EnumTrustedDomains(optional $Server)
; Returns an interleaved array: DomainName, DomainSid.
; If a server name is specified, the enumeration is based
; on the domain where the server resides. If no server is supplied,
; then the computer where the script is executing will be used by
; default.
$Domains = $Win32Admin.EnumTrustedDomains(@wksta)
if @error <> 0
? "@serror"
endif
for $i=0 to ubound($Domains) Step 2
? "Domain = " + $Domains[$i] + " Sid = " + $Domains[$i+1]
next



[ 08. October 2002, 13:27: Message edited by: Howard Bullock ]


Howard Bullock
(KiX Supporter)
2002-10-08 01:59 PM
Re: Win32Admin.DLL for your COMing pleasure

Here is a list of functionality I am considering adding to Win32Admin.DLL after completing the basic stuff.

User properties
Terminal Server user property support
NETLOGON support (secure channels, SAM replcation, etc)
Read/Write CAB files
Read/Write ZIP files
Create & manage child processes
DFS support (no place to test yet)
Socket support (maybe) Mini HTTP Daemon ?
Read/Write delimited files
ACL reading/modification

Has anyone looked at this yet? If so, what do you want to see in it?


Chris S.
(MM club member)
2002-10-08 02:27 PM
Re: Win32Admin.DLL for your COMing pleasure

I looked at it, but I saw it too late in the day to try it out.

What advantages does this have over ADSI methods?

I'd like to see some Exchange functionality added.


Chris S.
(MM club member)
2002-10-08 02:31 PM
Re: Win32Admin.DLL for your COMing pleasure

Oh yeah, and a BIGGIE would be remote execution of commands while passing user credentials to the remote client so the remote commands can access network resources. [Smile]

Howard Bullock
(KiX Supporter)
2002-10-08 02:37 PM
Re: Win32Admin.DLL for your COMing pleasure

I believe that it will be faster for most functions. Functionality outside the realm of ADSI can be included. Functions can be a composite of lower level operations providing greater functionality in a single call.

I am just exploring some new possibilites and potentially providing some benefit to fellow scripters.


LonkeroAdministrator
(KiX Master Guru)
2002-10-08 02:37 PM
Re: Win32Admin.DLL for your COMing pleasure

I like the socket but don't mind the html daemon.
 


ShawnAdministrator
(KiX Supporter)
2002-10-08 02:40 PM
Re: Win32Admin.DLL for your COMing pleasure

My list:

Terminal Server user property support
Create & manage child processes
Socket support (maybe) Mini HTTP Daemon ?
ACL reading/modification

and a mod:

Read/Write binary files

the last one might be tough to integrate into kixtart.

-Shawn

ps I like to see file handling like in the old unix stdio days ... you know ... things like binary read and writes and seeks and stuff.

[ 08. October 2002, 14:43: Message edited by: Shawn ]


ShawnAdministrator
(KiX Supporter)
2002-10-08 02:47 PM
Re: Win32Admin.DLL for your COMing pleasure

But I think I already mentioned this to you Howard - the number one thing I think would be most usefull is a simplified version of the ADsSecurity snapin. Like a COMable XCACLS with an interface that makes sense (for a change).

Les
(KiX Master)
2002-10-08 02:55 PM
Re: Win32Admin.DLL for your COMing pleasure

Speaking of ADsSecurity and the reg perms thing. I don't recall if anyone actually demonstrated how or if that can be done.

On the socket support, more than HTTP is desirable. Stuff like FTP, TELNET, etc.


Howard Bullock
(KiX Supporter)
2002-10-08 03:06 PM
Re: Win32Admin.DLL for your COMing pleasure

With time and more than a little reading/testing, I think most of what has been mentioned so far is doable.

FTP should be a no-brainer. I haven't played with telnet yet. Permissions are messy but possible.

{edit}
Remember that the DLL is somewhat large and will get larger as additional DLLs are bound inside to support things such as Perms, Sockets, etc. I just want to be clear that I was positioning this DLL as an Admin tool not a standard add-in for all clients.

[ 08. October 2002, 15:13: Message edited by: Howard Bullock ]


ShawnAdministrator
(KiX Supporter)
2002-10-08 03:14 PM
Re: Win32Admin.DLL for your COMing pleasure

The FTP thingy would be kinda neat - there are some commercial/freeware versions out there - but a board supported version would be much cooler.

In terms of ADsSecurity ... the bloody object model is way too complex and conviluted. Plus any script (I've seen) that use it - ends up sugar coating and wrapping all the functions anyways. It takes many dozens of lines just to setup perms on a share - its crazy !

[ 08. October 2002, 15:16: Message edited by: Shawn ]


Howard Bullock
(KiX Supporter)
2002-10-08 03:16 PM
Re: Win32Admin.DLL for your COMing pleasure

I don't believe I need to use ADsSecurity.DLL at all.

Howard Bullock
(KiX Supporter)
2002-10-09 03:42 AM
Re: Win32Admin.DLL for your COMing pleasure

Just added the ability to send SMTP email via KiXtart and Win32Admin.DLL.

[ 09. October 2002, 03:43: Message edited by: Howard Bullock ]


Chris S.
(MM club member)
2002-10-09 02:20 PM
Re: Win32Admin.DLL for your COMing pleasure

No attachments? [Wink]

I'll give it a try.


Chris S.
(MM club member)
2002-10-09 02:25 PM
Re: Win32Admin.DLL for your COMing pleasure

Hmm. I can Blat, but I can't W32_Mail.

{edit} My bad. It worked!

[ 09. October 2002, 14:26: Message edited by: Chris S. ]


Howard Bullock
(KiX Supporter)
2002-10-09 03:10 PM
Re: Win32Admin.DLL for your COMing pleasure

I didn't see a need for attachments from an Administrative script, but after I get Les' FTP installed, I may revisit mail.

[ 09. October 2002, 15:11: Message edited by: Howard Bullock ]


kholm
(Korg Regular)
2002-10-09 08:33 PM
Re: Win32Admin.DLL for your COMing pleasure

Howard,

I would like if you could split this util in two:
  • Communication part – containing FTP and Mail function
  • Admin part – containing the SAM/ADS functions
From scheduled/administrative tasks that checks if all servers/subnets/routers are alive i would only require the ability send small mails (no attachments)
Another serverside task could be scheduled downloads of antivirus definitions using FTP.
This is just a small wish, and if others don’t see the need for the split, or if the reuse of code is easyer using one bucket, just keep up eapanding the possibilityes [Wink]

Btw.
The only part i have tried is the mail-part, and that works like a charm.

-Erik


LonkeroAdministrator
(KiX Master Guru)
2002-10-09 08:49 PM
Re: Win32Admin.DLL for your COMing pleasure

well, for simplicitys sake some parts could be cut of to separate object...

like having a toolkit inside one dll.


Howard Bullock
(KiX Supporter)
2002-10-09 09:30 PM
Re: Win32Admin.DLL for your COMing pleasure

At this point in time I am limited to one object.

I can create multiple DLLs, but each one would be a minimum of ~500KB. I thought that one DLL/object with many methods would be easier to use/maintain as well as reduce disk space consumption and D/L time (1 vs many DLLs).

Since this is a work in progress, I am open to all suggestions about making this better and easier to use.

I wanted to use the Lonkero's different toolkits in one DLL, but am limited by the current compiler. As soon as I can figure out how to use different objects for COMM, ADMIN, ETC I will.

Until then I was hoping on feedback on the interleaved array implementation for returning related but dissimilar data. I could return a VB "Scripting.Dictionary" object, but that adds a WSH requirement on the client as well as a performance hit. Still looking for functionality and the best way to delivery it.

[ 11. October 2002, 00:11: Message edited by: Howard Bullock ]


LonkeroAdministrator
(KiX Master Guru)
2002-10-11 09:48 PM
Re: Win32Admin.DLL for your COMing pleasure

quess what is thing that could be added?

shortcuts.


Howard Bullock
(KiX Supporter)
2002-10-15 07:03 PM
Re: Win32Admin.DLL for your COMing pleasure

FTP implementation where I return an object that references the FTP server connection is not going well. My tool that makes the DLL does not return the this object type via COM at this time. The problem can be coded around but it would be very ugly. Or I can simply provide FUNCTIONs that would login to the FTP server, take some specified action (get, put, etc), then logoff based on some defined set of parameters. This would work much like the SMTP EMAIL function in Win32Admin.DLL.

comments...?

[ 15. October 2002, 19:45: Message edited by: Howard Bullock ]


LonkeroAdministrator
(KiX Master Guru)
2002-10-16 12:32 AM
Re: Win32Admin.DLL for your COMing pleasure

well,
I quess the poor support is better than no support... for now.


Les
(KiX Master)
2002-10-16 03:52 AM
Re: Win32Admin.DLL for your COMing pleasure

Howard,
The only need I've had for FTP is my NAV pattern checker/downloader.

Topic: NAV Pattern FTP Script RFC

It works though it's a bit convoluted. If it's not easy to include then don't sweat it.

Have you seen this post from guy you sometimes get mistaken for (or visa versa)?

Topic: [LIBRARY] Kix2001 Winsock object interface library v1.00a


Howard Bullock
(KiX Supporter)
2002-10-17 04:57 AM
Re: Win32Admin.DLL for your COMing pleasure

Added to Win32Admin.DLL:
  • FTP (get,put,size)
  • Random password generator
  • Rename groups or change group descriptions.
Reminder: 4.12 Beta 1 handles the COM errors if you encounter any. KiXtart 4.02 ABENDs when an error occurs, but does work when no errors are encountered.

[ 17. October 2002, 06:13: Message edited by: Howard Bullock ]


Howard Bullock
(KiX Supporter)
2002-10-19 06:07 PM
Re: Win32Admin.DLL for your COMing pleasure

Does anyone have any comments (good or bad) regarding the usablility of the functions in Win32Admin.DLL?

The web page where the DLL can be downloaded has seen 140 page hits since this thread was started, but no one has commented here or by email regarding their use of the code.

It is useful? Should I continue adding functionality? I know Shawn has a specific request. What about the rest of the community? Before I add more, I need to know if the current approach is usable.


MightyR1
(MM club member)
2002-10-21 01:25 PM
Re: Win32Admin.DLL for your COMing pleasure

I'd like to see TS support too...

LonkeroAdministrator
(KiX Master Guru)
2002-10-27 03:57 PM
Re: Win32Admin.DLL for your COMing pleasure

can't use before I get the sockets [Razz]

actually, need something to connect two of these, a listener and answerer...
you know, basic programmable connectivity.

the socket library is no goodie as it needs socketwrench and it's no goodie.


Les
(KiX Master)
2002-10-27 05:18 PM
Re: Win32Admin.DLL for your COMing pleasure

With Socket stuff, we could have the foundation for scripts to 'talk' to each other. That would allow for client and server scripts to handshake. The only way I know to do that now is with WaitFor.exe but it is limited in what messages may be passed. You end up having to pass info through text files.

I was looking also at MSMQ but it is over my head.


LonkeroAdministrator
(KiX Master Guru)
2002-10-27 05:22 PM
Re: Win32Admin.DLL for your COMing pleasure

mmm...
created some ircbot scripts with tcl and I can assure that connection does not need to be via files.
if we have sockets we can use real connections.
transferring simple files is slow and makes things slow.
it also needs some supporting stuff, like ftp server which is pretty much for simple "telnet" connection.


Howard Bullock
(KiX Supporter)
2002-10-27 05:27 PM
Re: Win32Admin.DLL for your COMing pleasure

I am still working on providing this functionality, but wouldn't you consider this DLL a little heavy to push to all clients?

Currently I use text files written to the local computer or registry entries to store messages and then write them to a network location when possible. A server side program monitors the directory and process the files as they are created.

Back to the DLL. I now have a workaround to the issue of returning objects back to KiXtart, but I as yet do not fully comprehend what is occurring and do not want to include code I can not fully support.

The next version of the compiler I am using has addressed this issue and will provide me and easier way of providing this functionality. I should be able to get a copy of the BETA compiler for building the DLL in a month or two.

I will see if I can implement IO sockets then.

[ 27. October 2002, 17:28: Message edited by: Howard Bullock ]


LonkeroAdministrator
(KiX Master Guru)
2002-10-27 05:31 PM
Re: Win32Admin.DLL for your COMing pleasure

heh.
I'm not pushing it on any client.
and this does not have to be the dll where it is.

I can't use registry writes to communicate with your wksta there as you probably know [Wink]
and that is the reason. I need a way to connect with kix via tcp in www not in lan/wan.


Howard Bullock
(KiX Supporter)
2002-10-27 05:33 PM
Re: Win32Admin.DLL for your COMing pleasure

Oh, I see. You have big plans. You going too compete with MSN and AOL?

Les
(KiX Master)
2002-10-27 05:36 PM
Re: Win32Admin.DLL for your COMing pleasure

I realize that you are focused on an admin DLL and not a client DLL. It's just that this is part of my dream list. Really, I think that Ruud should have this inter-script communication built-in. I think if we did a proof-of-concept that it might catch his eye.

What about this MSMQ stuff. Have you had a look at whether it could be used?


LonkeroAdministrator
(KiX Master Guru)
2002-10-27 05:38 PM
Re: Win32Admin.DLL for your COMing pleasure

maybe [Big Grin]

currently I just am starting with gaming stuff (like hearts network gaming).
also, I have huge interest in making some "telephone" connection stuff to do a interface with two pipes to talk some finnish to shawn without paying too much...

but, I'm just looking at the gaming stuff currently.

les, msmq?

also, I checked on the mediaplayer object...
do ye know if it is scriptable?


Les
(KiX Master)
2002-10-27 05:45 PM
Re: Win32Admin.DLL for your COMing pleasure

quote:
MSMQ Triggers
Server-only: This tool is included in the Windows 2000 Server Resource Kit only.

--------------------------------------------------------------------------------

MSMQ Triggers is Message Queuing application that allows you to associate incoming messages in a queue with functionality in a COM component or standalone .exe. As such, business rules can be invoked in response to such messages without any additional programming.

MSMQ Triggers works with Message Queuing for Microsoft® Windows® 2000 and MSMQ 1.0 for Microsoft® Windows NT® version 4.0.

MSMQ Triggers Concepts
Triggers are associated with specific queues on a computer and are invoked every time a Message Queuing message arrives at such queues. A trigger is comprised of one or more rules. These rules are defined by actions that will be invoked when all conditions associated with a rule are true.

A trigger is an automatic action taken in response to a message event. In the context of MSMQ Triggers, an event is defined as one or more conditions being satisfied with respect to a message arriving at a queue. The collection of all triggers on a particular computer is called the trigger set.

A condition is a test that is applied when a message arrives at a monitored queue. The condition can test for a property of a message only. A condition is always paired with an action.

An action is an executable behavior that is taken when a condition is true. An action can be expressed as an executable and argument list; or, a COM component, method, and argument list. Arguments are also called parameters.

A rule is an action-condition pair. A rule describes an action that will be taken when a specific condition is true. The collection of all rules (for all triggers) on a particular computer is called the rule set. A default rule handler, IMSMQRuleHandler, is used to test the condition and implement the action for a rule. This is the only supported rule handler.

An action is an executable behavior that is taken when a condition is true. An action can be expressed as an executable and argument list; or, a COM component, method, and argument list. Arguments are also called parameters.

A rule is an action-condition pair. A rule describes an action that will be taken when a specific condition is true. The collection of all rules (for all triggers) on a particular computer is called the rule set. A default rule handler, IMSMQRuleHandler, is used to test the condition and implement the action for a rule. This is the only supported rule handler.

The MSMQ Triggers Service reads messages from a monitored queue, that is, the service looks at such messages. Messages are not removed from queues by this service. It should be noted that another Message Queuing application may open the queue and remove messages before the MSMQ Triggers Service can looks at the queue.



Note

On Windows NT 4.0, a trigger cannot be associated with a private queue located on a remote computer.

Why Use MSMQ Triggers?
To provide message-handling functionality currently, applications developers must create a receiving application that invokes specific behavior on a per-message basis.

By using MSMQ Triggers, specific behavior can be invoked at a queue level. Application developers no longer need to write any infrastructure code to provide such message-handling functionality.

MSMQ Triggers Components
MSMQ Triggers consists of three separate programs. The first, Trigserv.exe, is the executable for running the MSMQ Triggers service. The second, Trigsnap.dll, is a snap-in DLL used in Microsoft Management Console (MMC) to manage triggers and define rules. The third, MSMQ Trigger Monitor (Trigmon.exe), is a troubleshooting application used to capture and display detailed trace and diagnostic information generated by the MSMQ Triggers Service.

MSMQ Triggers Topics

Installing MSMQ Triggers
Using MSMQ Trigger Manager
MSMQ Triggers Example
Troubleshooting MSMQ Triggers
Files Required

Msmqtriggers.exe - self-extracting setup program that installs MSMQ Triggers
Trigserv.exe - main executable file for the MSMQ Triggers Service
Trigobjs.dll - DLL that contains COM objects used by the MSMQ Triggers Service
Trigsnap.dll - snap-in DLL for MMC used to manage triggers and rules
Trigmon.exe - Microsoft® Visual Basic® executable for MSMQ Trigger Monitor
For More Information

For more information about Message Queuing, search the
Microsoft Web site.




Howard Bullock
(KiX Supporter)
2002-10-27 05:49 PM
Re: Win32Admin.DLL for your COMing pleasure

I installed MSMQ server on my test box but yet to find the require time to read, understand, and try something. I think that this type technology could be quite useful in the scripting world.