http://qs321.pair.com?node_id=309632


in reply to Re: Re: Win32 local users and groups modules
in thread Win32 local users and groups modules

Hi, I looked in my Roths Win32 Perl Scripting book and found several references to backing up and restoring machine and user accounts (pg 129). Also chapter 2 talks about Account Maintenance. I could only find a small reference on pg 200 that talks about group membership. I'll type it up if you like.

Most of the scripts relating to user and group stuff is Lanman though, maybe worth a look..? (Btw I think Jenda is responsible for this..)

This may also be worth a look..

I then looked at my Roths Win32 Perl Programming bookand think I found what you are looking for. On page 126 there is a section about Group Account Management which talks about Adding groups and adding users to groups. So here is a quick snippet. it uses win32::netadmin.

#! /usr/bin/perl use Win32::NetAdmin; my $machine = "\\\\server1"; my $group = "TestGroup"; my @users = qw(AcidHawk Fred Sally Bill); my $server = ""; Win32::NetAdmin::GroupCreate( $machine, $group, "This is a test group" +) or die "Cannot create group\n"; my $result = Win32::NetAdmin::LocalGroupAddUsers( $server, $group, \@u +sers); if ($result) { print "Successfully added users to $group\n"; } else { print "Failed to add users to $group\n"; }

Update: cpan:Win32::NetAdmin does have the following which may help

GroupGetMembers(server, groupName, userArrayRef) Fills userArrayRef with the members of groupName.
and
LocalGroupGetMembers(server, groupName, userArrayRef) Fills userArrayRef with the members of groupName.
as well as
GroupAddUsers(server, groupName, users) Adds a user to a group.
and
LocalGroupAddUsers(server, groupName, users) Adds a user to a group.
HTH..

-----
Of all the things I've lost in my life, its my mind I miss the most.

Replies are listed 'Best First'.
Re: Re: (3) Win32 local users and groups modules
by waswas-fng (Curate) on Nov 24, 2003 at 19:14 UTC
    Wow, great post, thanks for your help. I will have to run out and get the Win32 book, I never thought I would get stuck doing a project on that platform so it was not in my collection. Thanks again for everything.


    -Waswas