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.

Check if an account already exists?

Discussion in 'cPanel Developers' started by UltimateS, Jul 9, 2009.

  1. UltimateS

    UltimateS Registered

    Joined:
    Jul 9, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    How would i do that with the api?
     
  2. 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
    There are numerous calls that would allow for performing that sort of function. The main one that I can think of off hand would be calling accountsummary with the potential user passed as an argument to it. If you need more info, I can help you out tomorrow.
     
  3. Luke Carrier

    Luke Carrier Active Member

    Joined:
    May 27, 2009
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
  4. UltimateS

    UltimateS Registered

    Joined:
    Jul 9, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I will try that out, thanks. One more thing, how can i check if a domain is being used by any user?




    Sorry for all the questions.
     
  5. jhyland87

    jhyland87 Well-Known Member

    Joined:
    Dec 8, 2008
    Messages:
    153
    Likes Received:
    0
    Trophy Points:
    16
    This hasnt been tested, might work though.. 99% sure it will. as its just modified code I use.
    PHP:
    $exist false;
    $test_user "username";
    $str $xmlapi-> listaccts();
    $doc = new DOMDocument();            
    @
    $doc->loadHTML($str);        
    $s = @simplexml_import_dom($doc);
    $acct $s->body->listaccts->acct;
    foreach(
    $acct as $var => $value){
        
    $user     $value->user;
        if(
    $user == $test_user){
                   
    $exist true;
            }
    }
    if(!
    $exist){
    //user doesnt exist
    } else {
    //user does exist
    }
     
Loading...

Share This Page