5

我将如何在 Drupal 7 中设置没有模块的单点登录?我让它在 Drupal 6 中运行,但在 settings.php 文件中发生了一些变化,我很难弄清楚这一点。

 You can also use a reference to a schema/database as a prefix. This maybe
 * useful if your Drupal installation exists in a schema that is not the default
 * or you want to access several databases from the same code base at the same
 * time.
 * Example:
 * @code
 *   'prefix' => array(
 *     'default'   => 'main.',
 *     'users'     => 'shared.',
 *     'sessions'  => 'shared.',
 *     'role'      => 'shared.',
 *     'authmap'   => 'shared.',
 *   );
 * @endcode
 * NOTE: MySQL and SQLite's definition of a schema is a database.

这是我需要设置它的代码,我只是不知道将它放在我的 settings.php 文件中的什么位置。有任何想法吗?

4

4 回答 4

3

我的 setting.php 文件如下所示:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'driver' => 'mysql',
      'database' => 'drupal7',
      'username' => 'toto',
      'password' => 'xxxxxxxxxxxxxxx',
      'host' => 'localhost',
      'port' => '',
      'prefix' => array(
          'default'   => '',
          'users'     => 'drupal7_common.',
          'sessions'  => 'drupal7_common.',
          'role'      => 'drupal7_common.',
          'authmap'   => 'drupal7_common.',
          'languages' => 'drupal7_common.',
          'locales_source'   => 'drupal7_common.',
          'locales_target'   => 'drupal7_common.',
        ),
    ),
  ),
);
于 2011-02-15T13:44:28.420 回答
1

请允许我使用以下 settings.php 文件条目添加更多细节:

$my_db_users = 'dbusers.shared_';

$databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'dbdefault',
    'username' => 'databaseuser',
    'password' => 'databasepassword',
    'host' => '127.0.0.1',
    'port' => 3066,
    'prefix' => array(
        'default'   => 'default_', 
        'users'     => $my_db_users,
        'sessions'  => $my_db_users,
        'role'      => $my_db_users,
        'authmap'   => $my_db_users, 
    ),
    'collation' => 'utf8_general_ci',
);

在上面的例子中,我们设置了一个变量$my_db_users,等于共享用户数据所在位置的数据库和表前缀。

然后我们设置默认表前缀'default' => 'default_',:“除非另有说明,否则将所有表存储在defaultdatabase中,并使其表前缀为default_。” 我们还说:“将所有用户、会话、角色和用户角色映射 (authmap) 存储在具有表前缀shared_的数据库dbusers中。”

一个小转折:

考虑删除'authmap' => $my_db_users,线。如果您这样做,您可以在大型站点网络中拥有相同的用户和组,同时仍然允许用户在不同站点上具有不同的权限。在一个站点上,您可能是管理员,但在另一个站点上,您将是作者。

于 2012-08-01T15:27:49.640 回答
1

用于数据库配置的 Drupal 7 风格是这样的:

$databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'd7',
    'username' => 'drupaluser',
    'password' => '',
    'host' => '127.0.0.1',
    'port' => 33066,
    'prefix' => array(
      'node' => 'foo_',
    )
);

根据文档:

我在本地对其进行了测试,它似乎按预期工作。

于 2011-01-28T20:22:35.377 回答
0

要使用相同的登录凭据登录多个站点,您需要在 drupal setting.php 文件中进行一些更改。

这是这个功能的一个很好的教程:http: //drupixels.com/blog/single-sign-drupal-7

于 2013-12-14T06:25:37.567 回答