Multiple login scripts

Mike Brodbelt m.brodbelt at acu.ac.uk
Wed Jun 14 17:21:43 GMT 2000



ash at trellick.net wrote:
> 
> "A. Zuercher" <aaron at otherland.pekin.net> wrote:
> > scripts for each user, but this is unneccssary.  Instead is
> > there a group variable I could use to have staff.bat and a
> > student.bat login script run according to which group the
> > person is in?
> 
> I too am trying to do this.. I have dynamic logons working from the
> example in samba integrating unix and windows.. but need to get the
> groups from unix so I can use them to map drives in my perl logon
> script.
> 
> if any perl deity is hanging about.. please help.
 
This bit of code should do what you want. It takes a username as a
command line argument, and returns a list of the groups that user is a
member of. You can pull the username from Samba, and then chain this in
to do whatever you like.

#!/usr/bin/perl

$username = $ARGV[0] || die "Need a username!\n";

while (($name, $passwd, $gid, $members) = getgrent) {
        @members = split(/\s/, $members);
        foreach (@members) {
                if (/$username/) {
                        push(@groups,$name);
                }
        }
}

foreach (@groups) {
        print "Found user in group: $_\n";
}


More information about the samba mailing list