Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:08:14+00:00 2026-06-11T22:08:14+00:00

SOLUTION Well, that’s what I get when I use a bit oldish Symfony2 release

  • 0

SOLUTION

Well, that’s what I get when I use a bit oldish Symfony2 release (2.0-RC6). It seems that there was a bug in __construct of RoleSecurityIdentity (reported back in December ’10).

Instead of instance of Role it should be instance of RoleInstance.

I should probably close this question…


I’m pretty new to whole ACL concept in Symfony2 but I understand basics behind it. Last night I was trying to make next scenario work:

I have 2 user roles (ROLE_GROUP1, ROLE_GROUP2) and I want to setup object-level ACL for the one of these groups. If user with ROLE_GROUP1 is logged in it should put this role into ACE, otherwise it should put ROLE_GROUP2.

So far I wrote this code (really almost identical to official docs):

$role = $this->getRole(); // returns ROLE_GROUP1 role object

$acl_provider = $this->get('security.acl.provider');

$objIdentity = ObjectIdentity::fromDomainObject($object); // my object

$acl = $acl_provider->createAcl($objIdentity);

$securityIdentity = new RoleSecurityIdentity($role->getRole()); // Role based identity

$acl->insertObjectAce($securityIdentity, MaskBuilder::MASK_OWNER);
$acl_provider->updateAcl($acl);

The way I understand it, this should grant all permissions to users with ROLE_GROUP1 role. Am I wrong?

To check for permissions I used this code (again, from official docs):

$context = $this->get('security.context');

if ( false === $context->isGranted("EDIT", $object) ){
    throw new AccessDeniedException();
}

… but it always fails (that is throws an exception).

I looked into the ACL tables and everything seemed normal, as far as I could see.

Am I doing something wrong with RoleSecurityIdentity? Is there any way to achieve this scenario?

Any help would be much appreciated!

EDIT

I just drilled down through the Symfony’s code and found out that permission grant fails in equals method of RoleSecurityIdentity.

if (!$sid instanceof RoleSecurityIdentity) {
    return false;
}

/** I ADDED THIS IF CHECK TO SEE WHAT DOES IT COMPARE WITH **/
if ( $this->role->getName() == "ROLE_GROUP1" ){
    die("<pre>" . print_r($sid->getRole(),1) . "</pre><pre>" . print_r($this->role,1) . "</pre><pre>" . print_r($this->role === $sid->getRole(),1) . "</pre>");
}

return $this->role === $sid->getRole();

It turns out that $sid->getRole() is string “ROLE_GROUP1” while $this->role is Role object of ROLE_GROUP1 role.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:08:15+00:00Added an answer on June 11, 2026 at 10:08 pm

    Just to mark this question as resolved.


    Solution:

    Well, that’s what I get when I use a bit oldish Symfony2 release (2.0-RC6). It seems that there was a bug in __construct of RoleSecurityIdentity (reported back in December ’10).

    Instead of instance of Role it should be instance of RoleInstance.

    I should probably close this question…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Similar questions have been asked but cannot find a solution that works well. What
Is there any well-known algorithm (or obvious solution) for transforming a list from order
Rails has the rest autho plugin which works well but is there a solution
There's a strange problem with DotNetZip that I can't seem to find a solution
SOLUTION Make sure in the plist that the storyboard name is listed as the
Even though the linux man page for wait 1 explains very well that you
Now that i am thinking about it, it seems unusual that i dont know.
I am well aware that this is a noob question but i cant seem
It's well known that using forward declarations is preferable to using #includes in header
I'm well aware that the general rule of thumb is you should only import

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.