The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

help me how to suspend an account

Discussion in 'cPanel Developers' started by hamed23100, Jan 24, 2009.

  1. hamed23100

    hamed23100 Member

    Joined:
    Jul 31, 2008
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    I am programmer with asp, can you please help me how can i suspend an account with asp programming or someone help me with an script that suspend an account and then i pass domain name and parameteres to php script and then it reply back to asp script?

    Regards,
    Hamed
     
    #1 hamed23100, Jan 24, 2009
    Last edited: Jan 24, 2009
  2. wsenter

    wsenter Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Texas
    You could always just use PHP curl to suspend the account. Here you go...

    Code:
    <?php 
    // start the session and pass the Session parameter
    session_start(); 
    header("Cache-control: private"); //IE 6 Fix
    
    ######### Set up basic variables #########
    $serverIPaddress="192.168.1.1:2087";
    $whmusername="root";
    $whmpassword="123456";
    $server="https://$whmusername:$whmpassword@$serverIPaddress";
    
    //set the username of the account you are working with
    $user = "bobby12";
    $agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
    
    
    
    ######### Here are few example of many of the items that you could do with curl.  It will not execute until the very bottom #########
    
    //change user's password
    $url="$server/scripts/passwd?password=$passwd&domain=$user&user=$user";
    
    //enable shell access		
    $url="$server/scripts2/domanageshells?user=$user&shell=Enable+Jailed+Shell&user=$user";
    
    //bandlimit increase		
    $url="$server/scripts2/dolimitbw?user=$user&bwlimit=$bndwidth";
    		
    //suspend an account
    $url="$server/scripts2/suspendacct?domain=$user&user=$user&suspend-domain=Suspend&reason=";
    
    //UN-suspend an account
    $url="$server/scripts2/suspendacct?domain=$user&user=$user&unsuspend-domain=UnSuspend&reason=";
    
    //add front page extensions
    $url="$server/scripts/installfp?domain=$user&user=$user&submit-domain=Install";
    
    //remove front page extensions
    $url="$server/scripts/uninstallfp?domain=$user&user=$user&submit-domain=UnInstall";
    
    //modify the quota on the account		
    $url="$server/scripts/editquota?user=$user&quota=$quota";
    
    //add a domain pointer
    $url="$server/scripts/park?txtdomain=&domain=$domain&ndomain=$NewDomain";
    		
    //modify the account
    $url="$server/scripts/saveedituser?user=$user&BWLIMIT";
    $url.="=$BWLIMIT&FEATURELIST=$FEATURELIST&IP=$IP&OWNER";
    $url.="=$OWNER&PLAN=$PLAN&STARTDATE=$STARTDATE&DNS=$domain";
    $url.="&RS=$RS&LANG=english&newuser=$user&seeshell=$shell&MAXPOP";
    $url.="=$MAXPOP&MAXFTP=$MAXFTP&MAXLST=$MAXLST&MAXSUB=$MAXSUB&MAXSQL";
    $url.="=$MAXSQL&MAXPARK=$MAXPARK&MAXADDON=$MAXADDON";
    
    //generate a csr
     //need to replace spaces in all of the variables with the '+' sign
    $host = str_replace(" ","+",$host);
    $country = str_replace(" ","+",$country);
    $state = str_replace(" ","+",$state);
    $city = str_replace(" ","+",$city);
    $cod = str_replace(" ","+",$cod);
    $co = str_replace(" ","+",$co);
    $email = str_replace(" ","+",$email);
    $pass = str_replace(" ","+",$pass);
    $url="$server/scripts/gencrt?xemail=$xemail&host=$host&country";
    $url.="=$country&state=$state&city=$city&co=$co&cod=$cod&email=$email&pass=$pass";
    		
    ######### execute curl #########
    
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
    curl_setopt($ch, CURLOPT_MAXREDIRS, 4);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 120);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    $buffer = curl_exec($ch);
    curl_close($ch);
    
    ?>
    
     
    #2 wsenter, Jan 26, 2009
    Last edited: Jan 26, 2009
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Our XML API will work with any programming language that can work with XML and HTTP/HTTPS. You can read more about our XML API at:

    http://www.cPanel.net/plugins/xmlapi

    Basically you would pass some parameters to a special URL in WHM beginning with xml-api/ and you will receive results back to your script (ASP, PHP, Perl etc.) in XML format.
     
  4. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    In short, if you are able to setup a secure connection to WHM (which I have no clue as far as how to do that with asp) you simply call:

    Code:
    /xml-api/suspendacct/user=bob&reason=I%20do%20not%20like%20bob
    
    Full documentation is available at http://www.cpanel.net/plugins/xmlapi/suspendacct.html

    This will return an xml document that will contain all relevant information on the suspension.
     
  5. bmcniff01

    bmcniff01 Member

    Joined:
    Oct 15, 2008
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    For ASP the equivalent of cURL that you would want to use in this application is HTTPWebRequest.
     
Loading...

Share This Page