summaryrefslogtreecommitdiff
path: root/lib/RHRD
diff options
context:
space:
mode:
Diffstat (limited to 'lib/RHRD')
-rwxr-xr-xlib/RHRD/rddb.pm19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/RHRD/rddb.pm b/lib/RHRD/rddb.pm
index 3957459..894c03e 100755
--- a/lib/RHRD/rddb.pm
+++ b/lib/RHRD/rddb.pm
@@ -575,13 +575,26 @@ sub add_group_member
{
my ($dbh, $groupname, $username) = @_;
- my ($cnt, $result, $errostring) = is_group_member($dbh, $groupname, $username);
+ my $sql = qq{select count(*) from USERS where LOGIN_NAME = ?;};
+ my $sth = $dbh->prepare($sql)
+ or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
+
+ $sth->execute($username)
+ or return (undef, 'ERROR', "Database Error: " . $sth->errstr);
+
+ my ($cnt) = $sth->fetchrow_array();
+ $sth->finish();
+ if($cnt < 1) {
+ return (undef, 'ERROR', "user '" . $username . "' does not exist");
+ }
+
+ ($cnt, my $result, my $errostring) = is_group_member($dbh, $groupname, $username);
if($cnt > 0) {
return (undef, 'ERROR', "already a member");
}
- my $sql = qq{insert into USER_PERMS (GROUP_NAME, USER_NAME) values (?, ?);};
- my $sth = $dbh->prepare($sql)
+ $sql = qq{insert into USER_PERMS (GROUP_NAME, USER_NAME) values (?, ?);};
+ $sth = $dbh->prepare($sql)
or return (undef, 'ERROR', "Database Error: " . $dbh->errstr);
$cnt = $sth->execute($groupname, $username)