Failed ARO/ACO node lookup - php

I'm getting a weird error when running through the tutorial in the e-book, "Practical CakePHP Projects" in chapter 8, "A Cake Control Panel". Everything is built out, the DB is set-up and completely blank, and I'm running through the test at the end of the chapter to verify everything is working... I'm not sure what happened, but I keep running into the following error:
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 2
[username] => admin
[group_id] => 1
[created] => 2010-07-05 12:07:45
[modified] => 2010-07-05 12:08:00
)
)
It looks like it's telling me that there is no node in my Aro that is identified by the model 'User' with the id of '2'. But looking at my Aros table, I can clearly see that the last record is the following:
id:4, parent_id:2, model:User, foreign_key:2, alias:User:2, lft:2, rght:3
And the following relative record is my users table:
id:2, username:admin, password:hashed, group_id:1, created:date, modified:date
Where am I going wrong? Any direction someone could point me in would be greatly appreciated.
Thanks!

If you've setup the ACLExtras Automated tool to sync ACOs, Execute the following command in the CakePHP console:
./Console/cake AclExtras.AclExtras aco_sync

It seems for me that you either do not have corresponding record in acos table or permission in acos_aros. If that is the case you will need to add $this->Auth->allow('*'); in beforeFilter() in you app_controller.php and after that add ACO(s) and allow it to admin user.
I would advice you to follow official tutorial Simple Acl controlled Application because the information in the book becomes outdated. Something may not work with CakePHP 1.3.

Related

What is the best way to troubleshoot this error with parent::find?

I'm trying to build a PHP RESTful service using PhalconPHP. I'm new to PHP, so this may be a beginner question. I am following a tutorial https://www.toptal.com/phalcon/phalcon-php-restful-apis, and in the tutorial there is a section where it makes a call to pull the list of users.
public static function find($parameters = null)
{
return parent::find($parameters);
}
I am passing in a list of parameters listed below.
Array
(
[conditions] =>
[bind] => Array()
[columns] => users_id
)
but I keep getting a 500 error. I'm fairly sure it has to do with how I am connecting (or in this case, NOT connecting to the database).
I'm not 100% sure on what the 'parent' part does either, nor how it connects up to my MySQL database - I think I've gotten the config setup, and I've passed in the tablename that I'm expecting it to be under, but I have no idea if it's actually connecting up and then failing, or if the call itself is failing. So far I've tried echo and print_r with as many variables as I can find, but so far I'm not getting any information on why this is failing.
What is a good way to go about troubleshooting this? How can I find out what the 'parent' is? How can I find out if I'm connecting to my database even, or if it's failing before then?
In your concrete example, the quotes are missing in your conditions and columns parameters, it should be:
$users = Users::find(
[
'conditions' => '',
'bind' => [],
'columns' => "users_id"
]
);
Which should return a list of users ids (if any).
That tutorial from Andrew Belousoff is very good but maybe the next step after Phalcon's REST tutorial, since it explains step by step the inner workings of Phalcon.
For debugging, you can also check Phalcon's guide about it: https://docs.phalconphp.com/en/3.4/debug
And after Belousoff, you can dive into deeper waters with this one: https://github.com/phalcon/phalcon-api
Error 500 means error in php, just check logs. Im not sure how this parent thing is related to phalcon. This is just OOP, you mean you are using framework without knowledge about php/oop? Parent is just parent class which you extends.

MongoDb: db.getUser() in PHP

I'm currently writing an app in PHP that connects to a MongoDB database.
I've managed to successfully authenticate a user with the dbAdmin role in the MongoDB Database that I've setup, and I've created a user "TestUser" with no roles that I want to get information about while authenticated as the dbAdmin User. however I can't figure out how to run the "db.getUser()" command from PHP.
My understanding is that I should be able to use the "MongoDB::command()" method to run any actual mongoDB commands directly, however, the following code...
$mongo = new MongoClient("localhost:27017");
$mongoDb = $mongo->{'test'}
$mongoDb->authenticate($username, $password); //This returns a successful response of array('ok' => 1)
print_r($mongoDb->command(array("getUser" => "TestUser")));
Generates this response: -
(
[ok] => 0
[errmsg] => no such command: getUser
[code] => 59
[bad cmd] => stdClass Object
(
[getUser] => TestUser
)
)
The "getUser" is a command of a Database in MongoDB though, right? If so, why am I getting this response, and how do I construct a correct statement to be able to get information about a User from MongoDB in PHP?
I looked into this more, by fetching a list of all possible methods available to the database by using...
$mongoDb->command(array("listCommands" => 1));
This informed me that "getUser" apparently is not an existing command. I'm not sure why not, I guess it's because it's a User Management command and not a typical Database Command.
At any rate, "usersInfo" is a command that is available. By doing the following...
$mongoDb->command(array("usersInfo" => array("user" => $username, "db" => $database)));
I was able to get the data about the user that I wanted, so I guess that answers my question. Hopefully this helps anyone else whose encountering the same problem trying to setup their PHP app with MongoDb.

EOAuthUserIdentity getting error on getting token

I am using jorgebg/yii-eoauth library. I use the library with Yii EAuth extension. By requirements yii eauth
Requirements
Yii 1.1 or above
PHP curl extension
loid extension
EOAuth extension
Well, I come across with this problem. I checked it in local with linkedin account (no social accounts work on local server, except linkedin ) and it works perfectly. But login system doesn't work on server. Can you help me in this case ? Thanks in advance !
I didn't write my code here, because I thought, the problem doesn't depend on my code. If it is not, I can put here necessary code.
EDIT:
Error was :
Argument 1 passed to EOAuthUtils::GetAccessToken() must be an instance of
OAuthConsumer, instance of __PHP_Incomplete_Class given, called in
protected/extensions/eoauth/EOAuthUserIdentity.php on line 138 and defined
In line 138 of EOAuthUserIdentity.php was written:
// Upgrade to access token.
$token = EOAuthUtils::GetAccessToken($consumer, $token, $oauthVerifier,
$this->provider->access_token_endpoint);
I put logger pre($consumer,1); before above code. and I had in local:
OAuthConsumer Object
(
[key] => 7........k
[secret] => s........r
[callback_url] =>
)
I had on server:
__PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => OAuthConsumer
[key] => 7.........k
[secret] => s........r
[callback_url] =>
)
the same php version on local and server
You need load class before unserialize object. If u don't do this, object unserialize to __PHP_Incomplete_Class.
see PHP problem with "__php_incomplete_class"

CakePHP On Last step of ACL setup

I know there are several threads asking similar questions - but I havent found any real answers to solve this specific syntax error, I have followed the tutorial over and over again and still end up with these error - I know its looking for a missing node in relationship between the ACL and ACO - ugh, please help
Warning (512): DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:
Aro: Array
(
[User] => Array
(
[id] => 1
[username] => admin
[group_id] => 1
[created] => 2012-06-15 14:20:44
[modified] => 2012-06-15 14:20:44
)
)
Aco: controllers/Pages/display [CORE/Cake/Controller/Component/Acl/DbAcl.php, line 79]
It looks like your app can't find the aco record for the display action of the Pages controller. The quickest way to ensure you have all your aco's loaded into your db is use the AclExtras Plugin, this will scan through your controller files and add all actions to your aco table.

Add LDAP entry to Active Directory via ext/ldap

Using ext/ldap I'm trying to add entries to an Active Directory. As long as I only use one single structural objectClass everything works as expected, but as soon as I try to add an entry with a second auxiliary objectClass, the server reports an error:
Server is unwilling to perform; 00002040: SvcErr: DSID-030F0AA0,
problem 5003 (WILL_NOT_PERFORM), data
0
The following code works:
ldap_add($ldap, 'OU=Test,OU=Test,DC=domain,DC=example,DC=local', array(
'ou' => 'Test',
'objectClass' => 'organizationalUnit',
'l' => 'location'
));
This doesn't:
ldap_add($ldap, 'OU=Test,OU=Test,DC=domain,DC=example,DC=local', array(
'ou' => 'Test',
'associatedDomain' => 'domain',
'objectClass' => array('organizationalUnit', 'domainRelatedObject'),
'l' => 'location'
));
The same happens if I try to add an auxiliary objectClass to an existing entry:
ldap_mod_add($ldap, 'OU=Test,OU=Test,DC=domain,DC=example,DC=local', array(
'associatedDomain' => 'domain',
'objectClass' => 'domainRelatedObject'
));
The corresponding error message is essentially the same
Server is unwilling to perform;
00002040: SvcErr: DSID-030508F8,
problem 5003 (WILL_NOT_PERFORM), data
0
As all other updating and adding operations work, I think the problem must be related to the objectClass attribute.
As I've not enough experience with Active Directories (I'm used to OpenLDAP):
Are there any known issues with objectClasses in Active Directory? Am I missing something here? Are there any restrictions that disallow adding e.g. domainRelatedObject to an organizationalUnit? What the heck 's going on here ;-)?
Just in case you're wondering: the domainRelatedObject is present in the Active Directory schema.
I just found that, in order to add dynamic (per-instance) aux classes, the forest functional level of the domain must be 2003.
You may not have permission to set the objectClass attribute. See whether you can attach the auxiliary class after creation, through ADSI Edit. If you can't, fix the permissions first (check the Properties tab in the Advanced view of Security settings)
I could attach this specific class right now, onto a organizationalUnit object, as a domain admin; so in principle, this is possible.

Categories