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.

How to verify if login can be used ?

Discussion in 'cPanel Developers' started by zone-vip, Aug 27, 2008.

  1. zone-vip

    zone-vip Member

    Joined:
    Oct 16, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Franconville, Val-d'Oise, France
    Hello,

    I'm currently programming a reseller automated system based on cPanel.
    I actually have a little problem : during the registering, the user must choose a login.

    I want to verify if the login already exists or not and I don't seems to be able to do that.

    The only thing to know this if to try to create a new account, and at this moment, if the request return me a "Sorry, that username is already taken. Check /usr/passwd", it's that this login already exists.

    Is there any solution to test the login before creating a new account, or simply list all usernames that are on cPanel ?

    Thanks for your help,

    Vincent 'hokys' Composieux
     
    #1 zone-vip, Aug 27, 2008
    Last edited: Aug 27, 2008
  2. 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
    You can search for an existing user account using our XML API as documented here:

    http://www.cpanel.net/plugins/xmlapi/listaccts.html
     
  3. zone-vip

    zone-vip Member

    Joined:
    Oct 16, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Franconville, Val-d'Oise, France
    Thanks for your reply.

    When i call this url to test your XML API :
    http://mydomain.com:2086/xml-api/listaccts?searchtype=user&search=*=vincenth

    the XML returns me :

    Code:
    Erreur d'analyse XML : aucun élément trouvé
    Emplacement : http://mydomain.com:2086/xml-api/listaccts?searchtype=user&search=vincenth
    Numéro de ligne 3, Colonne 1 :
    ^
    When i try to create an account with this username using the PHP Accounting API, it returns me :

    Code:
    0 Sorry that username (vincenth) is taken. Check /etc/passwd 
    (it's normal, i created him before, but the API don't list me the user list, using listaccts() like it's specified here : http://www.cpanel.net/remoteaccess-php.html).

    Any other solution ?
     
  4. 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
    The XML-API should not be returning that. If a user is not found, it will return:

    Code:
    <listaccts>
    <status>1</status>
    <statusmsg>Ok</statusmsg>
    </listaccts>
    −
    <!--
     Web Host Manager  (c) cPanel, Inc. 2008 http://cpanel.net/  Unauthorized copying is prohibited. 
    -->
    What is the full version number for your installation of cPanel/WHM?
     
  5. zone-vip

    zone-vip Member

    Joined:
    Oct 16, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Franconville, Val-d'Oise, France
    I'm using cPanel 11.23.6-RELEASE build 26881.
     
  6. 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
    Hmm, several XML-API issues were resolved in 11.23.6. Were you calling this URL by entering it into your address bar in your web browser? If so, were you logged into WHM at the time as a root-level user or reseller?
     
  7. zone-vip

    zone-vip Member

    Joined:
    Oct 16, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Franconville, Val-d'Oise, France
    Yes i'm calling the URL in a web browser.
    When i call it, i'm logged with a reseller account. Is there a problem ?

    Thanks and sorry for the time you spend ...
     
  8. 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
    There shouldn't be an issue. However, as a reseller, you would only have access to knowing the usernames of users you own. Ideally, it would be the root user handling this via the APIs.

    As a reseller, the only alternative I am aware of is similar to what you are doing right now. Though in the long-term you may wish to consider moving to the XML-API as it offers more functionality than the older accounting system.
     
  9. zone-vip

    zone-vip Member

    Joined:
    Oct 16, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Franconville, Val-d'Oise, France
    Ok, i will try this manipulation on the root-level account.

    However, i will certainly move to use the XML-API.

    Thanks for all,

    Vincent 'hokys' Composieux
     
  10. zone-vip

    zone-vip Member

    Joined:
    Oct 16, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Franconville, Val-d'Oise, France
    Just for information : it works perfectly with a root-level account. Thanks ;-)

    I asked to my admin to turn the "list accounts" to enable and it works with my reseller account to.
     
  11. zone-vip

    zone-vip Member

    Joined:
    Oct 16, 2007
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Franconville, Val-d'Oise, France
    Hum, another little question : Is it possible to create a root-level account with the only privilege to list the cPanel users, or simply remove some rights to give him the minimum ? (just for security)
     
  12. 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
    At this time, this functionality is not present in cPanel/WHM. Feel welcome to request it at http://bugzilla.cPanel.net
     
Loading...

Share This Page