Description

This function retrieves a directory's authorized users from the .htaccess file.

Examples 


https://hostname.example.com:2087/cpsess##########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Htaccess&cpanel_jsonapi_func=listuser&dir=%2Fhome%2Fexample%2Fpublic_html%2Fheavensdoor

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Check authorized users who can knock on "heavensdoor" directory.
$authorized_users = $cpanel->api2(
    'Htaccess', 'listuser', 
    array(
        'dir' => '/home/example/public_html/heavensdoor',
    ) 
);

 

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Check authorized users who can knock on "heavensdoor" directory.
my $authorized_users = $cpliveapi->api2(
    'Htaccess', 'listuser',
    { 
        'dir' => '/home/example/public_html/heavensdoor',
    }
);

 

cpapi2 --user=username Htaccess listuser dir=%2Fhome%2Fexample%2Fpublic_html%2Fheavensdoor

{
  "cpanelresult": {
    "apiversion": 2,
    "func": "listuser",
    "data": [
      {
        "user": "bobdylan"
      },
      {
        "user": "wzevon"
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Htaccess"
  }
}

   

Parameters

ParameterTypeDescriptionPossible valuesExample
dirstring

Required

The directory's name.

The absolute path to the directory. /home/example/public_html/heavensdoor

Returns

ReturnTypeDescriptionPossible valuesExample
 array of hashesAn array of hashes that contains information about each authorized user.This array of hashes includes the user return. 

user

string

The authorized user's username.

The function returns this value in the unnamed hash.

A valid cPanel username.bobdylan
reasonstring

A reason for failure.

This function only returns a reason value if it failed.

A string that describes the error.

This is an error message.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1