[Samba] Active Directory, Listing Users in Groups.
sharif islam
sharif.islam at gmail.com
Fri Nov 19 22:39:53 GMT 2004
On Fri, 19 Nov 2004 16:30:27 -0600, Michael Wray <mwray at aimconnect.com> wrote:
> I have samba 3.0.8, as a member of 2000AD and 2003AD.
> I would like to get groups and the members in each group.
>
You can use 'getent group' command. I have a perl script that use,
gives the group and name. It is nothing fancy and works for me.
-------------------perl script--------------
#!/usr/bin/perl
# 03.15.04 sharif islam
# Provide a group name this looks for the groupname
# in the domain then loops through the list of user ids and gets
the full name
my $usage_string = "Find who is in a group
----------------------------------------------------
USE: ./group.pl GROUPNAME
OUTPUT:
group name at the top
user1
user2 ";
# Check for number of args.
if ($#ARGV < 0)
{
print "$usage_string\n" ;
exit 0 ;
}
# get the group name
$group = $ARGV[0];
#example: staff:x:621:username1,username2
$cmd = "getent group|grep -w $group";
$rv = `$cmd` ;
if($rv)
{
@out = split /:/, $rv ;
}
else
{ print "There's no such group as $group\n"; exit 0;
}
print "Group Name: $out[0]\n";
print "----------------------\n";
@names = split /,/, $out[3] ;
foreach $netid (@names)
{
$cmd = "getent passwd|grep -w $netid";
$rv1 = `$cmd`;
if($rv1)
{ @name = split /:/, $rv1 ; }
print "$name[4]\n";
}
---------------------script ends-------------------
More information about the samba
mailing list