View Full Version : Creating new databases as admin

11-28-2006, 05:32 AM

I've found CMD_API_DATABASES, but I don't understand where DA gets the username in "(username_ will be added)" from. Is it the user that logs in to create the database?

If so - is there a way I can create databases for a user *as admin*, by defining the accounts username I'm creating the database for?

My goal in case there's a different/better way of doing it:
I have several users on a non-DA server I wish to convert. I'll dump their databases from the old server, and recreate them on DA (with the API above?), do some fiddling with the database-names, and then insert the dump into the newly created databases.


11-28-2006, 06:31 AM
That means that the user's username will prefix the database name you specify (username_yourdbname).
The name of the database is sent using the name parameter, the username goes in user , and the passwd fields are for the database's password.

11-28-2006, 07:39 AM
From what I can understand, the 'user'-field you send is the database-username, not the account-username:

Form values:
Name | Value
action | create
name | the name of the database to be created (username_ will be added)
user | the name of the database user to be added (username_ will be added)
passwd | password for username_user
passwd2 | password for username_user

So if I make a form with the following fields:

name = testdb
user = testuser
passwd = somepass
passwd2 = somepass

I would get:

A database called <something>_testdb
A database-user called <something>_testuser
With the password 'somepass'.

I might be wrong though, as I haven't actually tried.

11-28-2006, 07:50 AM
Hm, yes, that might be true, didn't notice it I guess.
My guess is that it uses the username with which you are accessing the API. If that is true, it'd be nice if the DA staff is willing to add an extra optional parameter allowing you to create databases on other user's accounts.

11-28-2006, 08:04 AM
Yeah, that's what I figured too.

Maybe there's some way through the API to "become" a different user, like the "Log in as <user>" in the web-gui? I don't store my customers passwords in cleartext, so can't log in as them.

11-28-2006, 10:05 AM
As you may know you can achieve the effect of clicking the 'Login as ...' button also by entering this in the regular login form:

Username: your own admin username followed by a pipe | and the user's username
As password your own admin password

(so if my admin account was 'admin' with password 'zeekyboogydoog' and I wanted to log in as user 'loginasme', then I'd enter admin|loginasme as username and zeekyboogydoog as password)

(adminusername and adminpassword are your own, username is the name of the user you want to log in as)
I have the feeling that you can do exactly the same thing on the API as well, assuming the DA staff didn't do the rather useless job of writing a seperate login system for the API when it uses exactly the same algorithm and user accounts.

11-28-2006, 11:52 AM
Nice, I didn't know that. I'll give it a try. :)