Author Topic: Avoid using @domain.com  (Read 5244 times)

Offline rknetwork

  • Newbie
  • *
  • Posts: 8
Avoid using @domain.com
« on: August 17, 2008, 11:53:05 AM »
I want my users to avoid using @domain.com in the Username field when they login, so I have added the following lines to this file:

roundcubemail\program\include\main.inc

(assuming all of my users have CNAME of webmail.domain.com setup)

===================================
>>$domain_name = $_SERVER['SERVER_NAME'];
>>$domain_name = str_replace('webmail.', '', $domain_name);

  if ($sql_arr = $USER->get_identity())
    $s_username = $sql_arr['email'];
  else if (strstr($_SESSION['username'], '@'))
    $s_username = $_SESSION['username'];
  else
>> $s_username = $_SESSION['username'].'@'.$domain_name;
//.$_SESSION['imap_host'];

  return $s_username;
  }
===================================

This does not seem to work. Any solutions?

Thanks

Offline dj2

  • Jr. Member
  • **
  • Posts: 40
Avoid using @domain.com
« Reply #1 on: August 17, 2008, 12:09:03 PM »
In the main.inc.php file, search for this:

Code: [Select]
$rcmail_config['username_domain'] = '';
Enter your domain between the '' and you'll be set.  (That's a single quote, not double)
« Last Edit: August 17, 2008, 12:11:07 PM by dj2 »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,862
Avoid using @domain.com
« Reply #2 on: August 17, 2008, 12:09:51 PM »
Look in config/main.inc.php and you will see:

// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
$rcmail_config['username_domain'] = '';

If you set this to your domain then it will be automatically added to the end of usernames that don't already have a domain. Something like:

// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple hosts
$domain_name = $_SERVER['SERVER_NAME'];
$domain_name = str_replace('webmail.', '', $domain_name);
$rcmail_config['username_domain'] = $domain_name;

is probably what you want or may be try HTTP_HOST instead of SERVER_NAME, I'm not sure which is better. Either way RC will then rewrite the usernames for you.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and moreā€¦

Offline rknetwork

  • Newbie
  • *
  • Posts: 8
Avoid using @domain.com
« Reply #3 on: August 17, 2008, 12:17:51 PM »
Quote from: JohnDoh;13340

$domain_name = $_SERVER['SERVER_NAME'];
$domain_name = str_replace('webmail.', '', $domain_name);
$rcmail_config['username_domain'] = $domain_name;


Thanks, that works perfectly. I also added these lines to
\program\include\rcmail_template.inc
so users can see their @domain.com after Username field in bold.

============================================
  $domain_name = $_SERVER['SERVER_NAME'];
  $domain_name = str_replace('webmail.', '', $domain_name);

[ .. skipped .. ]

$fields[user]@$domain_name
============================================

Offline walshb6413

  • Newbie
  • *
  • Posts: 1
Where Exactly
« Reply #4 on: September 10, 2008, 07:31:12 PM »
Where did you place those lines in the .inc?  I can't seem to get it to show up...?

Thanks..

Offline rknetwork

  • Newbie
  • *
  • Posts: 8
Avoid using @domain.com
« Reply #5 on: September 10, 2008, 11:42:53 PM »
Quote from: walshb6413;13784
Where did you place those lines in the .inc?  I can't seem to get it to show up...?

Thanks..

Here is a bigger cut:

  if ($fields['host'])
    
$form_host = <<<EOF
    
</tr><tr>

<td class="title"><label for="rcmloginhost">
$labels[host]</label></td>
<td>
$fields[host]</td>

EOF;

  
$OUTPUT->add_gui_object('loginform'$form_name);

  
$domain_name $_SERVER['SERVER_NAME'];
  
$domain_name str_replace('webmail.'''$domain_name);
  
  
$out = <<<EOF
$form_start
$SESS_HIDDEN_FIELD
$fields[action]
<table><tr>

<td class="title"><label for="rcmloginuser">
$labels[user]</label></td>
<td nowrap>
$fields[user]<b>@$domain_name</b></td>

</tr><tr>

<td class="title"><label for="rcmloginpwd">
$labels[pass]</label></td>
<td>
$fields[pass]</td>
$form_host
</tr></table>
$form_end
EOF;
« Last Edit: September 12, 2008, 10:39:48 AM by bpat1434 »

Offline rknetwork

  • Newbie
  • *
  • Posts: 8
Avoid using @domain.com
« Reply #6 on: March 10, 2009, 05:58:41 AM »
So, how to be with the new version 0.2-stable?

rcube_template.php has completely changed

Could not find any place to add the following

============================================
$domain_name = $_SERVER['SERVER_NAME'];
$domain_name = str_replace('webmail.', '', $domain_name);

[ .. skipped .. ]

$fields[user]@$domain_name
============================================

Offline jeffshead

  • Full Member
  • ***
  • Posts: 71
Avoid using @domain.com
« Reply #7 on: May 29, 2009, 06:18:48 PM »
Quote from: rknetwork;17564
So, how to be with the new version 0.2-stable?


I second that! Anyone care to help with making this work with the current version?