I have a problem!
I want share users tables across more drupal sites... i read the page of handbook that explain how share tables...
all seem to works fine but there are a problem:
if a user create his account in the siteA and login in the siteB, he have an access denied, because the user isn't in the users_roles table of siteB. In this way the user isn't an "authenticated user" for siteB but only for siteA.

I can resolve the problem sharing users_roles table... but this is a good solution? in this way i must use same roles for users in both sites...

Suggest?

Comments

Lupin3rd’s picture

I have solved the problem with a mod to the users module.
I have change this:

// Reload user roles (delete just to be safe).
    db_query('DELETE FROM {users_roles} WHERE uid = %d', $array['uid']);
    foreach ($array['roles'] as $rid) {
      db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $array['uid'], $rid);
    }

Whit this:

// Reload user roles (delete just to be safe).
    db_query('DELETE FROM dbA.users_roles WHERE uid = %d', $array['uid']);
    foreach ($array['roles'] as $rid) {
      db_query('INSERT INTO dbA.users_roles (uid, rid) VALUES (%d, %d)', $array['uid'], $rid);
    }
// Reload user roles (delete just to be safe).
    db_query('DELETE FROM dbB.users_roles WHERE uid = %d', $array['uid']);
    foreach ($array['roles'] as $rid) {
      db_query('INSERT INTO dbB.users_roles (uid, rid) VALUES (%d, %d)', $array['uid'], $rid);
    }

In this way the users are "user authenticated" in both sites.

Steven’s picture

What you can do is use table prefixing to map one site's user-tables to the others.

$db_prefix = array(
"default" => "slave.",
"users" => "master.",
"sessions" => "master.",
"role" => "master.",
"authmap" => "master.",
"sequences" => "master.",
"users_roles" => "master."
);

Where "master" and "slave" are the database names. You can add any other table that needs sharing here.

--
If you have a problem, please search before posting a question.

Lupin3rd’s picture

With my little mod at users module (in all sites that share users must be modded) i can only share two tables:

$db_prefix = array(
"default" => "slave.",
"users" => "master.",
"sequences" => "master.",
);

In this way all sites have own users roles, own authoritation map, own sessions.
I only share the users, and i hope that it's a very good solution.