Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

using perl to collect NT groups

by semio (Friar)
on Jan 21, 2003 at 17:42 UTC ( #228762=perlquestion: print w/replies, xml ) Need Help??

semio has asked for the wisdom of the Perl Monks concerning the following question:

fellow monks,

I recently started using the Win32::NetAdmin module to assist with routine auditing tasks. For this, I put together the following script that will collect account info on a server.

#!perlenv -w use strict; use Win32::NetAdmin qw(UserGetAttributes GetUsers); my @users; my $server = $ARGV[0]; if ( $#ARGV < 0 ) { print "usage: ntinfo.pl <server IP address>"; exit; } GetUsers( $server, 0, \@users ); my ( $user, $password, $passwordAge, $privilege, $homeDir, $comment, $ +flags, $scriptPath ); foreach $user (@users) { UserGetAttributes( $server, $user, $password, $passwordAge, \$privilege, $homeDir, $comment, $flags, $scriptPath ); my $current = time(); my $days = $current - $passwordAge; print "$user:" . scalar( localtime($days) ) . ":$comment\n"; }
The problem is, I would like to also include the groups defined on any given server as part of the output of this script...something comparable to GetUsers, such as GetGroups perhaps. Looking through Win32::NetAdmin, it does not appear that this feature is available...I could be wrong though. Any ideas on this?

cheers, -semio

Replies are listed 'Best First'.
Re: using perl to collect NT groups
by LD2 (Curate) on Jan 21, 2003 at 18:00 UTC
    You probably want to look into using Win32::AdminMisc instead.. check out the GetGroups function.

    Hope that helps.
      thanks for the suggestion LD2. This appears to be exactly what I'm looking for...just a small problem. It appears as if the latest adminmisc dll requires perl v5.6 I'm currently using v5.8.0. I'll have to look more into this.
Re: using perl to collect NT groups
by Mr. Muskrat (Canon) on Jan 21, 2003 at 17:58 UTC
    Probably not what you are looking for but Win32::NetAdmin has GetUserGroupFromRID(server, RID, returnedName).

    Retrieves the name of an alias (i.e local group) or a user group for a RID from the specified server. These functions can be used for example to get the account name for the administrator account if it is renamed or localized.

Re: using perl to collect NT groups
by meetraz (Hermit) on Jan 21, 2003 at 18:45 UTC
    The module I use most for NT Administration is Win32::Lanman - It offers pretty much everything I need. I've also used Win32::NetAdmin and Win32::AdminMisc, but those are less full-featured.

    One of the best features of Win32::Lanman is that all the function names & arguments are straight out of the Win32 API, so if you're already familiar with that, it's much easier to use. Plus, you can search through Microsoft's MSDN for more information on these calls if you need more info than what is provided in the documentation.

    Here's the Win32::Lanman group-related functions:

    Win32::Lanman::NetUserGetGroups
    Win32::Lanman::NetUserGetLocalGroups
    Win32::Lanman::NetUserSetGroups
    Win32::Lanman::NetGroupAdd
    Win32::Lanman::NetGroupAddUser
    Win32::Lanman::NetGroupDel
    Win32::Lanman::NetGroupDelUser
    Win32::Lanman::NetGroupEnum
    Win32::Lanman::NetGroupGetInfo
    Win32::Lanman::NetGroupGetUsers
    Win32::Lanman::NetGroupSetInfo
    Win32::Lanman::NetGroupSetUsers
    Win32::Lanman::NetQueryDisplayInformation

    Lots of good stuff.

    You could also use the Win32::OLE module combined with ADSI. And, if you are pulling groups from Active Directory you could use Win32::OLE with ADO.. this is my favorite method for accessing large AD collections. Our domain has over 61,000 computer objects and over 200,000 user objects.

Re: using perl to collect NT groups
by primus (Scribe) on Jan 21, 2003 at 18:18 UTC
    well, i found this:
    use Win32::DomainAdmin # ??? $result = Win32::DomainAdmin::GetGroups($server,\%groups);
    on google groups here but i didnt see the module on CPAN.

    though here is a download link to the module.

    give it a shot i guess... good luck

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://228762]
Approved by Mr. Muskrat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-10-23 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?