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 check if the username and password are valid?

Discussion in 'cPanel Developers' started by azio, Aug 8, 2012.

  1. azio

    azio Registered

    Joined:
    Aug 8, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hi,

    I'm wondering if there's a shell command the check whether the provided username and password are valid or not.

    What I'm trying to do is logging in the user into my control panel only is he has a valid and active cPanel account on the server.

    Your help would be appreciated.
     
  2. Eric

    Eric Administrator
    Staff Member

    Joined:
    Nov 25, 2007
    Messages:
    746
    Likes Received:
    11
    Trophy Points:
    18
    Location:
    Texas
    cPanel Access Level:
    Root Administrator
    Howdy,

    Usernames are all listed in /etc/passwd so that's a really quick way to find that information. As for password you would need to try to use it to know if it's accurate.

    Thanks!
     
  3. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    San Francisco, CA
    cPanel Access Level:
    Root Administrator
  4. charsleysa

    charsleysa Active Member

    Joined:
    Jul 18, 2011
    Messages:
    41
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Palmerston North, New Zealand
    cPanel Access Level:
    Root Administrator
    If writing your script in PHP you can use the cryptography functions to encrypt the password with the currently encrypted password in the shadow file as the salt, if the new encrypted password equals the old encrypted password then the password is correct otherwise it's incorrect.
     
Loading...

Share This Page