Author Topic: Using virtuser_query with two databases  (Read 3543 times)

Offline Hakke

  • Jr. Member
  • **
  • Posts: 13
Using virtuser_query with two databases
« on: March 29, 2014, 12:12:11 PM »
Hello,

i want to use the virtuser_query to fill the identity settings on first login of a user.

The standard-configuration of the plugin is:
Code: [Select]
$rcmail_config['virtuser_query'] = "SELECT email_address FROM database.table WHERE login = '%u'";
With this configuration setting i can set the field email in RC identies table..

Now: I also want to fill in the field name from a defined second database..

Can somebody help?

Offline Hakke

  • Jr. Member
  • **
  • Posts: 13
Re: Using virtuser_query with two databases
« Reply #1 on: March 29, 2014, 03:58:18 PM »
I tried something like that:

Code: [Select]
SELECT address, name FROM system.virtuser, system.names WHERE virtuser.virtuser = names.username AND virtuser = '%u'
In phpmyadmin the result works fine...

First column: Mailadress
Second column: Name

The following colums are empty so that i get the following error message:
Code: [Select]
DB Error: [1048] Column 'organization' cannot be null (SQL Query: INSERT INTO identities (changed, `email`, `name`, `organization`, `reply-to`, `bcc`, `signature`, `html_signature`, `standard`, user_id) VALUES (now(), 'Hakke@sub.domain.de', 'Hakke', NULL, NULL, NULL, NULL, '0', '1', '6610')) in /var/www/roundcube/roundcube-0.95/program/lib/Roundcube/rcube_db.php on line 416 (POST /?_task=login&_action=login)
How do i have to change my sql-query so that it is working? I dont want to fill organization, reply to etc...
« Last Edit: March 29, 2014, 07:12:09 PM by Hakke »

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365
Re: Using virtuser_query with two databases
« Reply #2 on: March 30, 2014, 04:18:29 AM »
I think this should be fixed in Roundcube, but you can do:

SELECT address, name, '', '', '', '', '' FROM ...

Offline Hakke

  • Jr. Member
  • **
  • Posts: 13
Re: Using virtuser_query with two databases
« Reply #3 on: March 30, 2014, 04:45:16 AM »
Thanks Alec!

This workaround works fine for me :-)

Should i make a record in your trac to fix this?

Offline alec

  • Hero Member
  • *****
  • Posts: 1,365