Koozali.org: home of the SME Server

Username containing dots and underscores

Offline pmiranda

  • **
  • 32
  • +0/-0
Username containing dots and underscores
« on: November 05, 2004, 02:27:06 PM »
The problem

Since version 4.0, if I remember well, SME Server, former E-Smith, do not allow usernames containing dots and underscores.

I do not agree with this policy: it is too restrictive compared with other operating systems ones, and is really annoying if you want to migrate user account from other systems, or integrate SME Server into an existing network.

As an example, think about usernames formed as "user_nn" or "account_yy", or about one Mr. Mario De Rossi that has always logged on every corporate system as "de_rossi_m".

The workaround

Or, better: my workaround.  ;-)

:idea: Caution: hard core hands down here! :idea:

Thanks to SME Server designers, the user account manipulation functions all belong to one PERL module, the file AccountsDB.pm in the directory /usr/lib/perl5/site_perl/esmith/.

In this file there is only one check on the username syntax, performed by the following line, near the bottom of the file, in the validate_account_name function:
Code: [Select]
return ($name =~ /[^0-9a-z\-]/ or $name !~ /^[a-z]/) ? undef : 'OK';

So, if you want to enable usernames with underscores and dots, all you have to do is modify the search string in the previous code as follows:
Code: [Select]
return ($name =~ /[^0-9a-z\-_]/ or $name !~ /^[a-z]/) ? undef : 'OK';
for underscores only,
Code: [Select]
return ($name =~ /[^0-9a-z\-_\.]/ or $name !~ /^[a-z]/) ? undef : 'OK';
for both underscores and dots.

The collision checks between usernames and pseudonyms seem to be performed correctly.

The solution

Of course, implementing my workaround in the distribution, and modifying all the involved panels accordingly.  :-)
Pierluigi Miranda
Responsabile Sistemi e Reti
Servizio Sistemi Informativi
Agecontrol S.p.A.

FoxFriend

validate_account_name in sme 5.5
« Reply #1 on: April 11, 2005, 10:59:12 PM »
I'm interested in the same modification on a sme 5.5
But the perl module is not the same.
Can you tell me in which one I can find the same validation function.

Thanks by advance

Offline pmiranda

  • **
  • 32
  • +0/-0
Username containing dots and underscores
« Reply #2 on: April 12, 2005, 10:08:45 AM »
Sorry, I fear not: I never installed E-Smith/SME 5.x releases.

If it can be of any use to you, from my memory the E-Smith 4.0.1 editing had to be applied on one of the action scripts, instead of a perl module as in the 6.0 release.

To find which one, you have to follow the manager panel logic for the user-create event...
Pierluigi Miranda
Responsabile Sistemi e Reti
Servizio Sistemi Informativi
Agecontrol S.p.A.

FoxFriend

That'sa beginning
« Reply #3 on: April 12, 2005, 09:59:10 PM »
Ok I waste a least 30 minutes editing all PM modules in the perl site directorie's.
I will try this way now (with better result ?).
Thanks for your clue.

njolin

Username containing dots and underscores
« Reply #4 on: April 12, 2005, 10:10:37 PM »
I was able to successfully edit the AccountsDB.pm file to allow for special characters, but then when I tried to reset password to enable the account, it said Account "" has invalid characters. and would not take.

Im using SME 6 by the way.  

Thanks

Offline pmiranda

  • **
  • 32
  • +0/-0
Username containing dots and underscores
« Reply #5 on: April 14, 2005, 01:51:02 PM »
Quote from: "njolin"
Account "" has invalid characters. and would not take.


Some typos in your editing or non-unix editor, maybe?
The workaround I posted has been sufficient to let me manage user password on every SME password panel...

Just to be sure, I just made a diff between my edited file and the origina one, and the result follows:
Code: [Select]
bash-2.05a$ diff  AccountsDB.pm AccountsDB.pm.original
515c515
<     return ($name =~ /[^0-9a-z\-\._]/ or $name !~ /^[a-z]/) ? undef : 'OK';
---
>     return ($name =~ /[^0-9a-z\-]/ or $name !~ /^[a-z]/) ? undef : 'OK';


perfectly equivalent to the edited line already posted.

Have a look at the web server error log, too...
Pierluigi Miranda
Responsabile Sistemi e Reti
Servizio Sistemi Informativi
Agecontrol S.p.A.

njolin

Username containing dots and underscores
« Reply #6 on: May 10, 2005, 10:18:25 PM »
I have looked over the code many times and am sure i have it right.  I edited using pico, and it lets me enter the username, but cannot reset the password.  

Is there another function that is called when resetting passwords?

you mentioned modifying panels.  Is there anything i have to modify to make this work?