Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: rknetwork on August 17, 2008, 11:53:05 AM

Title: Avoid using @domain.com
Post by: rknetwork 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
Title: Avoid using @domain.com
Post by: dj2 on August 17, 2008, 12:09:03 PM
In the main.inc.php file, search for this:

$rcmail_config['username_domain'] = '';
Enter your domain between the '' and you'll be set.  (That's a single quote, not double)
Title: Avoid using @domain.com
Post by: JohnDoh 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.
Title: Avoid using @domain.com
Post by: rknetwork 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
============================================
Title: Where Exactly
Post by: walshb6413 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..
Title: Avoid using @domain.com
Post by: rknetwork on September 10, 2008, 11:42:53 PM
Quote from: walshb6413;13784Where 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 = <<   



$fields[host]

EOF;

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

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









$form_host
$fields[user]@$domain_name
$fields[pass]

$form_end
EOF;
Title: Avoid using @domain.com
Post by: rknetwork 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
============================================
Title: Avoid using @domain.com
Post by: jeffshead on May 29, 2009, 06:18:48 PM
Quote from: rknetwork;17564So, 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?