Jump to content
  • 0

Adding Existing Cpanel Accounts - Username Issue


dubjuice

Question

I am trying to import my existing cpanel accounts into Blesta but I ran into an issue that the username needs to be between 1 and 8 characters??? i have several usernames with 9+ characters so i cannot connect the client profile in Blesta with the cpanel login.  Can i change this restriction somehow to allow usernames longer than 8 characters?

Link to comment
Share on other sites

16 answers to this question

Recommended Posts

  • 0

It's only been available to do longer than 8 characters since 11.40: http://features.cpanel.net/responses/remove-arbitrary-username-length-limit 

 

Open: /components/modules/cpanel/cpanel.php

 

Find:

public function validateService($package, array $vars=null, $edit=false) {

Then under it look for this:

			'cpanel_username' => array(
				'format' => array(
					'if_set' => true,
					'rule' => array("matches", "/^[a-z]([a-z0-9])*$/i"),
					'message' => Language::_("Cpanel.!error.cpanel_username.format", true)
				),

and then this:

				'length' => array(
					'if_set' => true,
					'rule' => array("betweenLength", 1, 8),
					'message' => Language::_("Cpanel.!error.cpanel_username.length", true)
				)
			),
Link to comment
Share on other sites

  • 0

I am trying to import my existing cpanel accounts into Blesta but I ran into an issue that the username needs to be between 1 and 8 characters??? i have several usernames with 9+ characters so i cannot connect the client profile in Blesta with the cpanel login.  Can i change this restriction somehow to allow usernames longer than 8 characters?

Good found .

Link to comment
Share on other sites

  • 0

Ok so i changed the line from:

'rule' => array("betweenLength", 1, 8),

to

'rule' => array("betweenLength", 1, 16),

 

now I dont get the error anymore however it then errors out with:

Unable to fetch the cPanel user file for <first 8 characters of the username>

so its still only trying to connect with 8, basically truncating it.  Is there somewhere it truncates the username? maybe in the database?

Link to comment
Share on other sites

  • 0

Ok so i changed the line from:

'rule' => array("betweenLength", 1, 8),

to

'rule' => array("betweenLength", 1, 16),

 

now I dont get the error anymore however it then errors out with:

Unable to fetch the cPanel user file for <first 8 characters of the username>

so its still only trying to connect with 8, basically truncating it.  Is there somewhere it truncates the username? maybe in the database?

 

 

You have to change both lines I gave you :)

Link to comment
Share on other sites

  • 0

I'm not sure I understand what to change in the first line. There doesn't seem to be a reference to length. Maybe I'm missing something. What should I change the line to?

 

It's what people call a Regex: http://en.wikipedia.org/wiki/Regular_expression.

 

			'cpanel_username' => array(
				'format' => array(
					'if_set' => true,
					'rule' => array("matches", "/^[a-z]([a-z0-17])*$/i"),
					'message' => Language::_("Cpanel.!error.cpanel_username.format", true)
				),
				'length' => array(
					'if_set' => true,
					'rule' => array("betweenLength", 1, 16),
					'message' => Language::_("Cpanel.!error.cpanel_username.length", true)
				)
			),
Link to comment
Share on other sites

  • 0

Sorry i saw the Regex line but i didnt really look it in detail, i thought it was just filtering to ensure that numeric characters were allowed.  I changed it to 'rule' => array("matches", "/^[a-z]([a-z0-17])*$/i"), but i still get the same error where it truncates the username after the save.  When i reopen the client page the control panel username continues to show as truncated to 8.

Link to comment
Share on other sites

  • 0

Sorry i saw the Regex line but i didnt really look it in detail, i thought it was just filtering to ensure that numeric characters were allowed.  I changed it to 'rule' => array("matches", "/^[a-z]([a-z0-17])*$/i"), but i still get the same error where it truncates the username after the save.  When i reopen the client page the control panel username continues to show as truncated to 8.

 

Not sure then, only generated ones should be only limited to 8, if you use longer it should save as that, but as it's not I must be missing something somewhere.

Link to comment
Share on other sites

  • 0

Undo the regex change you made for the cPanel module -- it's invalid.

 

Ok so i changed the line from:

'rule' => array("betweenLength", 1, 8),

to

'rule' => array("betweenLength", 1, 16),

 

now I dont get the error anymore however it then errors out with:

Unable to fetch the cPanel user file for <first 8 characters of the username>

so its still only trying to connect with 8, basically truncating it.  Is there somewhere it truncates the username? maybe in the database?

 

What action did you perform, and what command is issued via the API that results in that error: "Unable to fetch the cPanel user ..."? You should see it at the top of the input/output module logs, and the input logs should show the username being requested.

 

When adding new users without specifically setting your own username, it will still generate one 8 characters in length.

 

If you still experience an issue with usernames 8 characters or less, then it may be the API that needs to be updated. I haven't tested this, but you could try finding and updating (/components/modules/cpanel/apis/cpanel_api.php):

if ( ( $user != null ) && ( strlen( $user ) < 9 ) ) {

to

if ( ( $user != null ) && ( strlen( $user ) < 17 ) ) {

There is no other limitation on username length within Blesta.

Link to comment
Share on other sites

  • 0

Ok i Updated the API but that didnt seem to resolve it either.  I removed the existing service from the account and re-added the service this time with the 8+ characater username and it took it.  It seems that updating the service after its been added doesnt update the cpanel username properly.

 

Did you undo the regex change mentioned above? I don't see any reason why you wouldn't be able to update the username to 8+ characters if you made the other aforementioned changes. Module log info would be helpful.

Link to comment
Share on other sites

  • 0

yes i undid the regex changes and everything is working properly now, it seems that it only didnt work if the account was created in blesta prior to making the change.  I have since installed version 3.4 and its still working, not sure if this was a bug fix included now in 3.4

 

Hi im struggling with this at the moment can you explain what it is you did? id like to update mine to allow a greater limit as i came to blesta after i setup some sites and really don't want to reinstall them if it can be avoided

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...