Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: (3) Win32 local users and groups modules

by AcidHawk (Vicar)
on Nov 24, 2003 at 18:53 UTC ( #309632=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://309632]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2021-02-26 16:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?