Suspending user gives error

Thanks for Quick reply:

This is list functions whitch working correct and incorrect:

- List of Users OK
- Create User OK
- Create Custom User OK
- Suspend/Unsupend aby account NOT OK, error "Unknown Select Command"
- Delete User NOT OK, error "Unknown Select Command"
- Modify User OK
- Get User Usage OK
- User limits OK
- Get User Domains OK

- Create Reseller OK
- Create Reseller Custom OK
- List of Users owned by Reseller NOT OK, result is empty
- Delete Reseller NOT OK, error "Unknown Select Command"

- List Admins OK
- Create Admin OK
- Delete Admin NOT OK, error "Unknown Select Command"

- List of IPs OK
- Save User Email - PROPABLY NOT OK, empty result
- Save User Email for Ticket/Messaging system - PROPABLY NOT OK, empty result

- List Domains - NOT OK, empty result
- List Subdomains - NOT OK, error "You are not own that domain"

I will inform You about next API functions when I finish tests
 
- Create Database - NOT OK, return HTML login form in array
- Delete Databse - - NOT OK, "Database Deleted" for aby data, database can not exists
- Show Reseller Packages OK
- Show User Packages OK
- List POP accounts - NOT OK, error "You are not own that domain"
 
I would like to thank DirectAdmin Support for help with "You are not own that domain" problem. I will note that "Unknown Select Command" problem is still active.

Here is my sample PHP code

header('Content-type: text/plain; charset=UTF-8');

include('function.php');

$host = $_GET['ad1'];
$user = $_GET['ad2'];
$password = $_GET['ad3'];

$suspend = $_GET['suspend'];
$username = $_GET['username'];

$retval = DA_SSL_Request($user, $password, '/CMD_API_SELECT_USERS', 'POST', array('location'=>'CMD_SELECT_USERS', 'suspend'=>$suspend, 'select0'=>$username), $host);

echo json_encode($retval);

I found also that solution on some topic but albo doesn't work

$retval = DA_SSL_Request($user, $password, '/CMD_API_SELECT_USERS', 'POST', array('dosuspend'=>'1','select0'=>$username), $host);
 
I would like paste code from function.php file, I don't see EDIT POST function so I past new code on new post

function DA_SSL_Request($user, $password, $request, $method='GET', $post_content='', $host='localhost', $port=2222) {

$headers = '';
$headers[] = "Content-Type: application/x-www-form-urlencoded";
$headers[] = 'Content-length: ' . strlen($post_content);
$headers[] = 'Authorization: Basic ' . base64_encode("$user:$password");

$ch = curl_init();
$complete_url = 'http://' . $host . ':' . $port;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method . ' ' . $request . ' HTTP/1.1');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $complete_url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // Time out sec.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

$answer = curl_exec($ch);

if (!$answer) {
echo 'problem: '.$answer;
} else {
parse_str($answer, $answer);
}

return $answer;
}
 
Was the domain created by "admin"?
For email accounts, you must be logged in as the user who owns the domain.

Eg, if admin created fred, and fred owns domain.com, then to manage email accounts, your script must be logged in as "fred".

There are 2 ways to login as fred (the end-User).

1) Either use the username "fred" and that account's password, eg
Code:
$username = "fred";
$pass = "fredspass";
2) Or use the login-as method with the admin password:
Code:
$username = "admin|fred";
$pass = "adminpass";

Either one will log you in as "fred", then you can manage domain.com (owned by fred)

John

That's doesn't work. I don't know users passwords so I try login as user with admin password but on response I get HTML login form
 
Hello,

Run DA in debug mode.
Test with both your browser using the normal interface, and with your script.
Compare the 2 values to see how your script differs, and you'll know what to change.

http://help.directadmin.com/item.php?id=356

John

I ran DA on debug mode. Suspending/removing accounts from browser working correct ("User XXX Removed"), but I still get "{"error":"1","text":"Unkown Select Command","details":"none"}" as results. It's answer from Yours API. Can You check in which situactions that message is displayed
 
Amazing... 5 years later and CMD_API_SELECT_USERS is still throwing "Unkown Select Command" on any action.
 
Back
Top