Table of Contents
API examples
Get all users and print their username
The following script will get all activated users and print the username for each of them.
#!/usr/bin/perl
use Vhffs::Main;
use Vhffs::Constants;
use Vhffs::User;
my $vhffs = init Vhffs::Main;
my $users = Vhffs::User::getall( $vhffs , Vhffs::Constants::ACTIVATED );
my $user;
foreach $user ( @{$users} )
{
print “Username: ” . $user→get_username . “\n”;
}
exit 0;
Get all websites that belong to a specific group
The following script returns all the name of websites owned by the group mygroup. If no website exists, print “no website”.
#!/usr/bin/perl
use Vhffs::Main;
use Vhffs::Group;
use Vhffs::Services::Httpd;
my ( $vhffs , $webs , $web , $group );
$vhffs = init Vhffs::Main;
$group = new Vhffs::Group( $vhffs , “mygroup” , '401' );
if( $group→fetch < 0 ){
print “The group does not exist”;
exit 1;
}
$webs = Vhffs::Httpd::getall( $vhffs , undef , undef , $group );
if( ! defined( $webs ) ){
print “No website for this group\n”;
exit 2;
}
foreach $web ( @{$webs} ){
print “Website servername : ” . $web→get_servername . “\n” ;
}
exit( 0 );