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 user exists

Discussion in 'General Discussion' started by anarckie, Nov 8, 2002.

  1. anarckie

    anarckie Member

    Joined:
    Jul 10, 2002
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    I have a backend script and needed to know the easiest way of checking if a username already exists before creating the account...


    Something like:

    if (/home/$newuser&)
    {
    echo &username taken, please try again&; die;
    }


    Not sure what the paths would be though, any ideas?
     
  2. anarckie

    anarckie Member

    Joined:
    Jul 10, 2002
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Looks like i answered my own question.

    That works.


    Thanks guys ;)
     
  3. anarckie

    anarckie Member

    Joined:
    Jul 10, 2002
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Well i have another question.

    Does anyone know all the exempt variables for creating an account?

    Like: Username cant start with a number.
    & Username cant already exist
    &
    &
    &


    Those are the only i know of, anyone know any others i can protect myself again? :)
     
  4. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    You might have a look at the username checks in /scripts/wwwacct
     
  5. taivu

    taivu Well-Known Member

    Joined:
    Nov 22, 2001
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    [quote:84be928f70][i:84be928f70]Originally posted by anarckie[/i:84be928f70]
    if (/home/$newuser&)
    [/quote:84be928f70]

    I would suggest using /etc/passwd for the checking instead, since there are quite a few users that don't have a home directory (different daemon accounts etc.).
     
  6. anarckie

    anarckie Member

    Joined:
    Jul 10, 2002
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    [quote:c5c64d00d6][i:c5c64d00d6]Originally posted by taivu[/i:c5c64d00d6]
    I would suggest using /etc/passwd for the checking instead, since there are quite a few users that don't have a home directory (different daemon accounts etc.). [/quote:c5c64d00d6]

    Thanks, i change it.

    [quote:c5c64d00d6]You might have a look at the username checks in /scripts/wwwacct[/quote:c5c64d00d6]

    No i dont have access to that, can anyone look in there for me?
     
  7. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    - valid characters for WHM are alphanumeric, dot and dash only
    - user cannot exist in /etc/passwd
    - max username length is 8 (though not always it seems)
    - username cannot begin with a number
    - username cannot begin with a dash
    and that's it I think.
     
  8. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    In doing a Tutorial for creating FTP accounts, this is some of what I found to apply for that area:

    Characters Allowed

    Although you can use almost anything for creating an ID and/or PW -- and get a message saying &successful& -- some special characters cannot be used. All special characters keys on a keyboard, can be used for inclusion within an ID and/or PW except for the following:

    & ampersand
    ( left parenthesis
    ) right parenthesis
    | separator (found on the same key as the backslash)
    ; semi-colon
    & left angle bracket
    & right angle bracket

    Note: as odd as it may sound, you can even use * (shift+8 key) which amazes me!

    The bad news is, Cpanel will &always& show a successful setup, even if it will not work for an FTP account. It was only through trial & error (using every available key on a keyboard) that I was able to determine what worked and what didn't.


    Although the &not allowed& characters listed above will not work anywhere within an ID / PW, I was able to setup a FTP account using a Numeric character for the first digit.

    So it may be a handy (relevent?) reference for Hosting Account setup, but should be taken with a grain of salt.
     
  9. moronhead

    moronhead Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    706
    Likes Received:
    0
    Trophy Points:
    16
    Are you saying that you've found square brackets, [ and ] are acceptable for a username and FTP?
     
  10. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    Actually, no. As the above post was only an excerpt, certain parts had been left out.

    Although the allowed special characters can be used in any combination for PW's, they cannot with ID's. Haven't tested all the combinations yet for that.
     
  11. TedButz

    TedButz Registered

    Joined:
    Nov 9, 2002
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    lets see..
    youc an do
    if(strlen($user) & 8) {
    echo(&Too long&);
    die;
    } else {
    // Setup Account
    }
     
Loading...

Share This Page