Resller : Limit users

ben29

Verified User
Joined
Jul 20, 2006
Messages
449
Location
Israel
that feature can limit how much the resller can open users
for eexample limit of 10 users
if he want more, it will block the request by msg "you reach your limit"
 
I did ask the same time ago to DA Staff but they did had more important things to improove before this and did suggest me to use da pre/post scripts to acchieve this.

I did it so, if you want to use this way let me know and i'll share what i did.

Regards
 
Here it is:

/usr/local/directadmin/data/admin/custom_package_items.conf
Code:
users_number=type=text&string=Users Number&desc=Number of users that can be created.

/usr/local/directadmin/scripts/custom/user_create_pre.sh
Code:
#!/bin/sh

if [ "$usertype" != "user" ]; then

        exit 0;

fi

MAX_USERS=`cat /usr/local/directadmin/data/users/$creator/user.conf | grep users_number | cut -d= -f2`

if [ "$MAX_USERS" == "" ]; then

        exit 0;

fi

#obtains the exact number of domains on the system right now.  The tally is delayed, and cannot be used.
CURRENT=`wc -l /usr/local/directadmin/data/users/$creator/users.list | cut -d\  -f1`

if [ "$CURRENT" -ge "$MAX_USERS" ]; then

      echo "Maximum number of Users  ($MAX_USERS) have already been created.  Cannot create any more."
      exit 1;

fi

exit 0;

The first file add a custom package field when you create a user (every type of user), so, dont fill it up when you are creating a normal user.

The second will check what kind of user are you creating, if you are NOT creating a normal user, will skip the check, otherwise, if you are creating a normal user will check the max users allowed for the reseller (or admin), and, if the limit has been reached return an error that say "Maximum number of Users ($MAX_USERS) have already been created. Cannot create any more."

Hope it does help you, and also hope will be implemented as standard in DirectAdmin (maybe also better studied cause have no sense to have the voice of max_users when you're creating a normal user and not admin/reseller).

Regards
 
Back
Top