I have 2 sites on the same domain (example.com, site2.example.com) and I am trying to make them both reference the same user tables etc from the main site (example.com) in order to have single sign on through both.
I have 2 DBs set up - one for each - and have set up a user which can access both with all the required permissions. I have altered my settings.php in the second site as below (and numerous variations of):
$databases['default']['default'] = array(
'driver' => 'mysql',
'database' => 'database_site2',
'username' => 'multi_username',
'password' => 'multi_password',
'host' => 'localhost',
'prefix' => array(
'default' => 'database_site2.',
'users' => 'database_main_site.',
'sessions' => 'database_main_site.',
'role' => 'database_main_site.',
'authmap' => 'database_main_site.',
),
);
Unfortunately when then trying to access site2 after making this change, I get the following error message:
Uncaught exception thrown in shutdown function.
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in >your SQL syntax; check the manual that corresponds to your MySQL server version for the >right syntax to use near '-amalga-01.semaphore WHERE (value = >'1471293032527ac89955a330.73110726')' at line 1: DELETE FROM {semaphore} >WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => >1471293032527ac89955a330.73110726 ) in lock_release_all() (line 269 of >/home/sites/amalgamart.co.uk/public_html/exampletown/includes/lock.inc).
If someone is able to help me with this I would be forever grateful!
Thanks!
The "prefix" part of Drupal's db configuration refers to a string that is prepended to the table name within a single database, whereas you are trying to use two different databases. I don't think that this is possible in Drupal. Please read this, or you can try and see if Domain Access module could be suitable to your needs.
Related
Using Adldap2 package (https://adldap2.github.io/Adldap2/#/) and to be more accurate laravel version (https://github.com/Adldap2/Adldap2-Laravel) and having some issues with add/update some attributes after creation.
To be more specific, I will try to do this
Create user
$user = Adldap::make()->user([
'cn' => 'Vlad Test7',
'samaccountname' => 'vlad_test7',
'Company' => 'Company Name',
'givenname' => 'Vlad',
]);
$user->objectclass = [
'top',
'person',
'inetOrgPerson',
];
$user->save();
This will work.
But after if I will try to set another attribute like department, doing it as below
$user->setAttribute('Department', 'Information Systems');
$user->save();
I will get this error message
ErrorException : ldap_modify_batch(): Batch Modify: Insufficient access
at PATH_TO_PROJECT_ROOT\vendor\adldap2\adldap2\src\Connections\Ldap.php:386
I asked system admin about provided accounts permissions, and he told me that I have full access within OU for test user, that they have been created for me.
I suppose, that possibly can be something wrong with my config files, I have there as admin told me.
Here how config file (ldap.php) looks like
'hosts' => explode(' ', env('LDAP_HOSTS', 'corp-dc1.corp.acme.org corp-dc2.corp.acme.org')),
'port' => env('LDAP_PORT', 389),
'timeout' => env('LDAP_TIMEOUT', 5),
'base_dn' => env('LDAP_BASE_DN', 'dc=corp,dc=acme,dc=org'),
'username' => env('LDAP_USERNAME', 'username'),
'password' => env('LDAP_PASSWORD', 'secret'),
Based on my search result, possibly error message on update can be related with dn (distinguished name), as I have something like that as base_dn
base_dn=OU=TEST USER,OU=xxxxxx1,OU=xxxxxx2,OU=xxxxxx3,OU=xxxxxx3,DC=domain,DC=local
and when I'm creating a user, for new created user I'm getting new generated dn which is like below
dn=CN=Vlad Test7,OU=TEST USER,OU=xxxxxx1,OU=xxxxxx2,OU=xxxxxx3,OU=xxxxxx3,DC=domain,DC=local
not sure, is this correct or not? Thinking also about possibility, that I can't perform operations using generated distinguished names,when I'm creating a new record, at least impression is that I have added CN=Vlad Test7 to base_dn, which is causing the error.
Any suggestions or thoughts about this issue?
Thanks
Answer is simple, it was a permission issue of the AD user, which I'm using here, as error message describes, insufficient access, so nothing related with coding here.
I'm using Vagrant to start a VirtualBox VM in windows. I do:
$ vagrant ssh
To connect to the VM. Then I do $ mysql to connect to my database. Then I can see my DB that I have created to use. However When I go to my server I see this error:
The table "doe_user" for active record class "User" cannot be found in the database.
I know thats because the database is empty and the table User doesnt exist. thats why I tried to added tables to database using this :
load all tables in the doe_db: http://***.***.**.**/install.php;
When I run this, i get:
mysql> load all tables in the doe_db: http://***.***.**.**/install.php;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'all t
ables in the doe_db: http://***.***.**.**/install.php' at line 1,
when I use show databases then I select the correct database, then asking to show the tables it returns empty set.
when I go to my http://***.***.**.**/install.php I get:
Internal Server Error
Undefined index: log
An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.
Thank you.
Here is my database code:
$config_database = array(
'components' => array(
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=doe_db',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'enableProfiling' => true, //http://www.yiiframework.com/doc/guide/1.1/en/topics.logging
'enableParamLogging' => true,
),
),
);
Now when I visit: http://***.***.**.**/index.php
I get the error:
The table "doe_user" for active record class "User" cannot be found in
the database.
However when I change my databse code to:
$config_database = array(
'components' => array(
'db' => array(
'connectionString' => 'mysql:host=localhost;dbname=doe_db',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'enableProfiling' => true, //http://www.yiiframework.com/doc/guide/1.1/en/topics.logging
'enableParamLogging' => true,
),
),
);
And when I visit: http://***.***.**.**/index.phpI get:
CDbConnection failed to open the DB connection: SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
for my local host, when I want to access phpMyAdmin, I dont have any password for my root user.
You can refer MySQL - LOAD DATA INFILE to load the data from a file.
LOAD DATA INFILE 'http://***.***.**.**/install.php' INTO TABLE doe_db;
I'm currently building a site on drupal with the lime survey module. I tried configuring the synchronization between the limesurvey and my site.
I opened sites/default/settings.php, and added the lines below after the $databases['default']['default'] variable :
$databases['ls']['default'] = array(
'driver' => 'your_LimeSurvey_driver',
'database' => 'your_LimeSurvey_database_name',
'username' => 'your_LimeSurvey_database_username',
'password' => 'your_LimeSurvey_database_user_password',
'host' => 'your_LimeSurvey_host'
'prefix' => 'lime_' [or another value]
'collation' => 'utf8_general_ci' [or another value]
);
as instructed.
I first encountered this error( Parse error: syntax error, unexpected ''prefix'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\wamp\www\lime survey\drupal-7.24\sites\default\settings.php on line 235 ) and solved it by taking the '[or another value]' out of the code.
I'm now facing these errors (http://postimg.org/image/b6ynerdr1/) (http://postimg.org/image/io7utz3a5/) and i have run out of ideas. Please help me out
"your_LimeSurvey_driver" shouldn't be a literal value. You should change this to either 'mysql', 'pgsql' or 'sqlite' depending on the type of database you are using. It will probably be 'mysql'.
Similarly you should change 'your_LimeSurvey_database_name' etc to be actual names, usernames and passwords for the database, and 'your_LimeSurvey_host' should be the host the database is running on - likely to be 'localhost' or '127.0.0.1' depending on your setup.
I am using Laravel 4.0.10 and ccovey/ldap-auth for user authentication. On the server end I have OpenLDAP server created with Turnkey OpenLDAP. I've followed the instructions but I'm getting an error when trying to connect to server.
Error:
Bind to Active Directory failed. Check the login credentials and/or server details. AD said: Invalid DN syntax
My app/config/adldap.php file:
<?php
return array(
'account_suffix' => '#mreza.vpl',
'domain_controllers' => array("ldap.vpl.lan"), // An array of domains may be provided for load balancing.
'base_dn' => 'DC=mreza,DC=vpl',
'admin_username' => 'admin',
'admin_password' => 'mypassword',
'real_primary_group' => true, // Returns the primary group (an educated guess).
'use_ssl' => false, // If TLS is true this MUST be false.
'use_tls' => false, // If SSL is true this MUST be false.
'recursive_groups' => true,
);
I added this line to app/config/auth.php:
'username' => 'uid'
My OpenLDAP database looks like this:
I want to authenticate against People group
Any ideas what I am doing wrong? I've been trying to set this up for a few days now. I am new to LDAP though.
Thanks!
Change the Admin username to either cn=Admin or cn=admin,DC=mreza,DC=vpl and try to connect. You need a full DN to bind, generally.
Here is a snippet of the code I got from some tutorial blog:
<?php
class PersonalBlogController extends AppController {
var $name = 'PersonalBlog';
var $uses = array('PersonalBlog');
function index(){
//ini_set('max_execution_time', 300);
debug($this->PersonalBlog->findAll());
//debug($this->PersonalBlog->find('all'));
}
}?>
I have seen some other cases in max time limit fatal error from other posts. But mine is probably the most disgusting. The fatal 30 secs time limit error keeps coming even after I change the max_execution_time variable in php.ini. Even after changing it to 60 or 300 seconds, the error message stays the same. It says 30 seconds time limit is exceeded.
I then followed alternative solution from a similar question, which is to do this instead:ini_set('max_execution_time', 300); (See my commented code above).
The error is gone. However what happens after that is this:
Warning (2): PDO::__construct(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) [CORE\cake\libs\model\datasources\dbo\dbo_mysql.php, line 155]
.....
.....blablabla...
Fatal error: Call to a member function getAttribute() on a non-object in C:\Server\www\myserver.dev\public_html\cakephp-cakephp-7fbf7a4\cake\libs\model\datasources\dbo\dbo_mysql.php on line 259
So I realized that I actually have two MySQL server installed. The newest one (5.5.11) is on port 3307 not on port 3306! That is why I then changed my driver setting in the dbo_mysql.php:
/**
* Base configuration settings for MySQL driver
*
* #var array
*/
protected $_baseConfig = array(
'persistent' => true,
'host' => 'localhost',
'login' => 'root',
'password' => 'mysqlpassword',
'database' => 'personal_blog',
'port' => '3307'
);
Every other setting is normal; I have the same database setting for app>config>database file as you can see here:
public $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => 'mysqlpassword',
'database' => 'personal_blog',
'port' => 3307,
'prefix' => '',
);
After those changes, the warning still appears...I really feel like I want to throw up right now
Any help would be appreciated.thx
You shouldn't have to edit the dbo_config to manage the port setting. All of those keys are available for use in the database.php file in your app/config/ folder.
You actually shouldn't have your personal defaults in the dbo file at all -- nothing you are doing should ever edit any core files.
Once you have your port setting in ONLY the database.php file and your dbo driver is back to the one that shipped with cake you should delete all of the files in /tmp/cache and set your debug > 0 in app/config/core.php
Refresh and if the error is still occurring we know that something is messed up at the php.ini / .htaccess or ini_set level. Try adjusting the value and then loading a view that contains
<?php
phpinfo( );
?>
and see if the max execution time setting is actually being read by the php interpreter. If it isn't you might want to try the ini set method or htaccess methods of playing with that value. Also make sure the php.ini you are editing is the right one ( the path to the ini should be in the php info dump ) - you might find you have 2 versions of php loaded as well as your two versions of mysql.
If that doesn't solve or at least pinpoint the issue then post back here and let us know.