As far as I can tell you can't use the external user database directly. However, it should be possible to use a hook that accesses the user database in a login attempt.
This post from the owncloud form shows how the hook pre_login
is used. It checks for an LDAP group, but this should be easily adapted to your case.
Copy&paste of the essentials from the post:
Create a function that does the lookup in your database and returns true
when the user is valid.
File <owncloud>/apps/<your_plugin>/appinfo/hooks.php
OC::$CLASSPATH['OC_Templates'] = 'lib/util.php';
class OC_user_ldap_Hooks{
public static function IsUserInGroup($parameters) {
// replace this with your own database logic
$filter = "(&(cn=owncloudusers)(memberUid=".$parameters['uid']."))";
if(!OC_LDAP::searchGroups($filter, 'dn') && $parameters['uid']!="admin")
{
$tmpl = new OC_Template( '', 'error', 'guest' );
$tmpl->assign('errors',array(1=>array('error'=>"User <b>".$parameters['uid']."</b> is not a member of a group allowed to login.")));
$tmpl->printPage();
exit;
}
return true;
}
}
And in the file <owncloud>/apps/<your_plugin>/appinfo/app.php
OC::$CLASSPATH['OC_user_ldap_Hooks'] = 'apps/<your_plugin>/lib/hooks.php';
OCP\Util::connectHook('OC_User', 'pre_login', 'OC_user_ldap_Hooks', 'isUserInGroup')
This is just the basic to get you started, you will have to handle a little more (for example creation of a new user in ownCloud if a user logs in the first time).