Function to replace the user names cpanel?

Rigina

Registered
Sep 14, 2011
4
0
51
cPanel Access Level
Root Administrator
Hello,
Need to automatically replace the names (login) of all user cpanel. What API function can it perform?
Help me, please.
 
Last edited:

sirdopes

Well-Known Member
PartnerNOC
Sep 25, 2007
141
0
66
Are you wanting to change the usernames for all of the users? Do you have root access or are you wanting to do this as a reseller?
 

sirdopes

Well-Known Member
PartnerNOC
Sep 25, 2007
141
0
66
The following is a simple example on how to change a username with perl using cpanel's api.

Code:
#!/usr/bin/perl
use LWP::UserAgent;
use MIME::Base64;


my ($user, $newuser) = @ARGV;
if ((!$user) || (!$newuser)) {
        print "Usage: changeuser currentuser newuser \n";
        exit;
}
my $luser = "username";
my $lpass = "password";
my $ip = "127.0.0.1";
my $auth = "Basic " . MIME::Base64::encode( $luser . ":" . $lpass );

my $ua = LWP::UserAgent->new;
my $request =
HTTP::Request->new( GET =>
"http://$ip:2086/xml-api/modifyacct?user=$user&newuser=$newuser"
);
$request->header( Authorization => $auth );
my $response = $ua->request($request);
print $response->content;