Replace admin-c in multiple domains

 

 

#
# replace admin-c in multiple domains
#
#!/usr/bin/perl
use LWP::UserAgent;
use Data::Dumper;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => 'https://dmapi.joker.com/request/login?username='.shift().'&password='.shift());
my $res = $ua->request($req);
#--Admin-C :
my %ADMIN = ( de =>'CODE-12345' , org => 'CORG-12345', com => 'CCOM-12345', 'eu' => 'c12345' );
unless ($res->is_success) {
  print "Failed: ", $res->status_line, "\n";
  exit -1;
}
my $auth=$res->as_string;
my $output;
if ($auth =~ /Auth-Sid:\s*([a-z0-9]+)/m ) {
$auth = $1;
} else {
  print "Failed: Got no auth-id from DMAPI:\n";
  print $res->content;
  exit -3;
}
while ( <DATA> ) {
  chomp;
  my $fqdn = $_;
  ## for 3rd level domains this must be changed!
  my ( $sld, $tld ) = split ( /\./ , $fqdn );
  my $admin = $ADMIN{ $tld };
$req=HTTP::Request->new(GET => 'https://dmapi.joker.com/request/domain-modify?domain='.$fqdn.'&admin-c='.$admin.'&auth-sid='.$auth);
$res = $ua->request($req);
  if ($res->is_success) {
$output=$res->content;
     print $output;
  } else {
     print "Failed: ", $res->status_line, "\n";
     exit -2;
  }
}
__DATA__
domain1.de
domain2.eu
domain3.org
domain4.com
__END__


 

Tags: Code, DMAPI, example, perl

Related entries:

You cannot comment on this entry