Request: Restrict users to specific email domain
Moderator: mkoch227
-
- Posts: 15
- Joined: Fri Jun 05, 2009 9:33 pm
Request: Restrict users to specific email domain
/*************************************
Title:
Version:
Author:
Demo:
Download:
Website:
Short description:
*************************************/
Hi all,
just install Hesk and am incredibly impressed.
On thing I would like to be able to do is to limit users to email addresses within my email domain. Thus, if the email address does not end with "@mycompany.com" the user gets a warning message and either has to enter an "@mycompany.com" address or they can go no further.
Thanks,
Mike
Title:
Version:
Author:
Demo:
Download:
Website:
Short description:
*************************************/
Hi all,
just install Hesk and am incredibly impressed.
On thing I would like to be able to do is to limit users to email addresses within my email domain. Thus, if the email address does not end with "@mycompany.com" the user gets a warning message and either has to enter an "@mycompany.com" address or they can go no further.
Thanks,
Mike
Try this:
- open file "common.inc.php" (inside "inc" folder) in Notepad or Wordpad
- find this code (lines 202-211):
Change it to:
Didn't test it though, let us know if it works.
- open file "common.inc.php" (inside "inc" folder) in Notepad or Wordpad
- find this code (lines 202-211):
Code: Select all
if (preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$address))
{
return $address;
}
if ($required) {
hesk_error($error);
} else {
return '';
}
Code: Select all
if (strpos($address,'@yourcompany.com'))
{
return $address;
}
if ($required) {
hesk_error('Sorry, you need a @yourcompany.com address to continue!');
} else {
return '';
}
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
-
- Posts: 15
- Joined: Fri Jun 05, 2009 9:33 pm
You can change the text in the language file (inside "language" folder, open it in Notepad).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
-
- Posts: 15
- Joined: Fri Jun 05, 2009 9:33 pm
Re: Request: Restrict users to specific email domain
As on 2.3 version is there a way to do the same...
ie: the option have changed as it looks to be on line 990 an on...
i wanna have only 2 possible option @mydomain.com and @sub.mydomain.com
Thanks
ie: the option have changed as it looks to be on line 990 an on...
i wanna have only 2 possible option @mydomain.com and @sub.mydomain.com
Thanks
Re: Request: Restrict users to specific email domain
Replacing with this (twice in the code!) should work:
Any valid (sub)domains should be within ( ) separated by a |
Instead of . and - use \. and \-
Examples:
Code: Select all
"/([\w\-]+\@[\w\-]+\.[\w\-]+)/"
Code: Select all
'/(@domain\.com|@sub\.domain\.com)$/'
Instead of . and - use \. and \-
Examples:
Code: Select all
'/(@domain\.com)$/'
'/(@domain\.com|@sub\.domain\.com)$/'
'/(@domain\.com|@sub\.domain\.com|@some\-long\-domain\.com)$/'
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Request: Restrict users to specific email domain
Nice...
I've done in common.inc.php
Thanks
I've done in common.inc.php
Code: Select all
if ( ! preg_match('/([\w\-]+\@domain\.com|[\w\-]+\@sub\.domain\.com)$/',$v))
Code: Select all
if (preg_match('/([\w\-]+\@domain\.com|[\w\-]+\@sub\.domain\.com)$/',$address))
Re: Request: Restrict users to specific email domain
Hello,
is this also posible in 2.7.6?
thx.
is this also posible in 2.7.6?
thx.
Re: Request: Restrict users to specific email domain
The code changed a bit, but still doable; in inc/common.inc.php find and just ABOVE/BEFORE that code add
I strongly recommend you use a powerful text editor to make changes, such as the free Notepad++ (some editors, including Windows Notepad, won't save PHP files in the correct encoding).
Code: Select all
/* Character not valid in local part unless local part is quoted */
Code: Select all
// List of email domains accepted. Everything after @
$accept_domains = array(
'example.com',
'sub.example.com',
'another-example.com',
);
// Only accept emails from domains listed above
if ( ! in_array(strtolower($domain), array_map('strtolower', $accept_domains)) )
{
return false;
}
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Re: Request: Restrict users to specific email domain
Thank you so much!