Thread: CREATE USER possible?

CREATE USER possible?

From
"Adams, Joe"
Date:
I am trying to make a administration web page for postgreSQL users. The main
purpose of this web page is to add , remove and modify pgsql users. To do
this I am connecting to a database under the postgres user. The following is
only some of the code being used.

$dataSource="dbi:Pg:dbname=alidb";
$dbh = DBI->connect($dataSource, "postgres", "password");
if($dbh)
{
       $statement = "CREATE USER oadd WITH PASSWORD rspassword";
       #prepare and execute the statment
        $sth = $dbh->prepare($statement);
        $rc = $sth->execute;
        print "USER HAS BEEN ADDED<br>$ADDstatement<br>";
}

From what I understand and from talking to some people on #postgresql it
doesn't matter what DB I connect to, just that the user I connect with has
the rights to create other users.
I've looked for this topic in previous threads and am somewhat confused. Is
what I'm doing the correct approach. If not what would be the right approach
(ie running ./createuser ).

Someone else must have already written this  - - so I'd love to hear from
you.