phpBB3 Auth_IMAP
I wrote a plugin for phpBB3 to authenticate users through anything supported by the PHP IMAP functions (which includes the “IMAP protocol, as well as the NNTP, POP3 and local mailbox access methods”). For this to work you need to have PHP configured to load the imap extensions. The plugin supports authenticating users from two sources (a default source and a secondary source which is tried on failure of the first one).
Grab auth_imap.txt and upload it to your phpBB3 installation directory as includes/auth/auth_imap.php
Add to the bottom of language/en/acp/board.php (right before the ?>) the following block:
$lang = array_merge($lang, array(
‘IMAP_SERVER’ => ‘Auth_IMAP Connection String’,
‘IMAP_SERVER_EXPLAIN’ => ‘See php.net/imap for syntax, example is: {localhost/pop3:110}INBOX’,
‘IMAP_ALTSERVER’ => ‘Alternative Auth_IMAP Connection String’,
‘IMAP_ALTSERVER_EXPLAIN’ => ‘Same syntax as above, tried if user not valid from first connection string’,
));
To activate the IMAP Authentication under the phpBB3 Administration Control Panel go to Client Communication – Authentication and fill in the form.
Let me know if you found this helpful.
phpbb3 on 09 Jan 2008 at 9:49 pm #
1/. Why don’t this…
if (!$mbox) {
// CLOSE HERE
imap_close($mbox);
// Give status about wrong password…
return array(… );
}
imap_close($mbox);
2/. After i config used IMAP then Err and I can’t login my forum. Howto re-config authentication by DB?
3/. Thanks yous share!
tim on 09 Jan 2008 at 10:28 pm #
Re: 1:
If (!$mbox) then the stream wasn’t successfully opened and doesn’t actually need to be closed.
So, as it is, the flow is:
if success on the primary server, close that connection
if not success on the primary server no connection was opened, try the alternate server, and close closes that connection.
That being said, your suggestion isn’t wrong, and, as-is, it may be trying to close a connection that wasn’t created on the alternate server. The existing flow could be made more clear by checking function return values.
Re: 2:
If you can login as an administrator, under the Admin control panel, Client Communication – Authentication there’s a drop down with the list to select Db authentication.
If you can’t login, the way to change it manually in the database is to edit auth_method in the table phpbb_config to be “db”. (e.g. run the SQL: UPDATE phpbb_config SET config_value=’db’ WHERE config_name=’auth_method’ LIMIT 1;). I don’t know if there’s an easier way if you can’t login.
Re: 3:
You’re welcome and thanks for commenting. Hope this helps.
lmthong on 14 Jan 2008 at 1:45 am #
Hi Tim
I downloaded and used your plug-in, perfect. But, when there’re more than 2 user log-on, it said wrong password (I thought it could not authenticate with my imap server). I changed to pop3 but no better. I don’t know where caused my problem, form my phpBB3 or my mail server (I used MDeaMon with about 20000 accounts).
Please, help me.
Thanks.
lmthong on 14 Jan 2008 at 1:52 am #
Ah, more info: my mail server runs on Windows Server, and my web runs on Ubuntu
tim on 14 Jan 2008 at 6:58 am #
It’s difficult to tell without more debug information; but, I’d hazard a guess that your mail server may be rejecting connections if there’s too many in a short period of time from one computer.
If you could try changing line 28 and 33 to be:
OP_HALFOPEN) || die(imap_last_error());
that should give enough information to be able to track down the problem better. (You don’t want to leave that in on a production system since who are legitimately rejected would get an unfriendly looking page). Let me know where you get with that.