I have Drupal 7 using LDAP to connect to an AD server. I am able to create a new AD user (authenticates using CAS, not LDAP) and get the OG authorization to pull from a group that the user is a part of in AD. However, when I remove that group from that user in AD it still is part of that group in Drupal.

To the longwinded details:

*OG group already exists named Group1

Step 1: Tie Drupal into AD using LDAP module, test and verify it can do an ldapsearch
Step 2: Add new group in AD, let's call it DrupalA
Step 3: Add new user in AD, jane.doe, and make it a member of DrupalA
Step 4: Configure LDAP to OG group Configuration
-- Things in configuration to note:
--- Unchecked "Only apply when users authenticate via LDAP" (I use CAS at the moment)
--- II.B is selected and attribute name is "memberof"
--- III.A "Mapping of LDAP to OG group"
CN=DrupalA,CN=Users,DC=cas,DC=ad|Group1
--- "Use LDAP group to OG group filtering" checked
--- IV.B "When a user logs on" Checked
--- IV.C "Revoke" and "Re grant" checked
Step 5: Log in as new user
--- Excerpt from message in logs (debugging on)
jane.doe : initial proposed authorization for og_group: cn=drupala,cn=users,dc=cas,dc=ad.

jane.doe : filtered authorization for og_group: Group1

LdapAuthorizationConsumerOG.grantSingleAuthorization() beginning to grant authorization for $group_name=Group1 to user jane.doe

Notice: Undefined offset: 2 in LdapAuthorizationConsumerOG->grantSingleAuthorization() (line 235 of /etc/drupal7/all/modules/ldap/ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php).

LdapAuthorizationConsumerOG.grantSingleAuthorization() granted: gid=2, group_name=Group1 for username=jane.doe, result=1, OG role granted=, settings output =

LdapAuthorizationConsumerAbstract grantsAndRevokes() method log. action=grant:
consumer_id=Group1, op=grant,grant existing role, granting existing consumer object, ,result=1
	jane.doe :
user_authorizations_set results for og_group: authorization ids to add: %creates
revokes: none 
grants: Group1

User does get the proper OG assigned and can view the page associated with Group1. Although the logs complain a bit, things appear to be working fine for the user.

Step 6: Remove DrupalA group from user in AD
Step 7: Log in as jane.doe again
--- Excerpt from message in logs

jane.doe :_ldap_authorization_ldap_authorization_maps_alter: 
deriveFromDn authorization ids:
 deriveFromAttr authorization ids: 
deriveFromEntry authorization ids: 
authorizations: 
merged authz_ids authorization ids: 

jane.doe : initial proposed authorization for og_group: .

jane.doe : filtered authorization for og_group: .

jane.doe: 
LdapAuthorizationConsumerAbstract grantsAndRevokes() method log. action=grant:
no actions
jane.doe: 
LdapAuthorizationConsumerAbstract grantsAndRevokes() method log. action=revoke:
consumer_id=Group1, op=revoke,revoking existing consumer object, 
	jane.doe : 
user_authorizations_set results for og_group: 
authorization ids to add: %creates 
revokes: Group1
grants: none

But jane.doe still sees the Group1 page that is private only to that group. If I go to the Group1 membership, it still shows that jane.doe is still a member. I can manually delete her from the group and things work fine, but the revoke doesn't seem to be working.

Is there something I am missing?

Comments

johnbarclay’s picture

Title: Revoke of OG rights » LDAP OG: Revoke of OG rights
Version: 7.x-1.0-beta5 » 7.x-1.x-dev
Category: support » bug

Sounds like a bug to me. Can someone else who using ldap authorization OG try to reproduce this to verify its a bug?

johnbarclay’s picture

Priority: Normal » Major
Issue tags: +D7 stable release blocker
johnbarclay’s picture

Priority: Major » Normal

There are a number of issues I see with ldap og. One is that it stores the group membership by name. So if the group name changes, they lose membership. I'm attempting to rework the module some and add test coverage.

The scenario you can replicate is the correct behavior. OG Memberships manually created, should not be revoked by ldap_authorization_og module.
[ ] "Revoke OG groups previously granted by LDAP Authorization but no longer valid."

Try the following:

- in the database: select name, cast(data as char(1000)) from users
- take the results of the data field and run them through http://unserialize.net/serialize to deserialize them.

Somewhere in the array should be the following structure for the user you are testing with. This is the data that tracks if ldap_authorization_og created the membership. Try creating the membership by logging on and having the membership created automatically. And make sure that the record looks correct. Then change the ldap data and have them logon again. In this scenario the membership should be created and revoked. I had trouble getting this behavior working consistently, but it was my first time working with og in drupal 7.

Since I'm reworking the module, I wouldn't put much time persuing this unless you need to implement this now.

 'ldap_authorizations' => 
  array (
    'og_group' => 
    array (
      'ABC OG Test Group #1' => 
      array (
        'date_granted' => 1326599130,
      ),
    ),
  ),
johnbarclay’s picture

Status: Active » Needs review

I committed a fix to this in 7.x-1.x-dev. Its a rewrite of the module ldap authorization og, but does revoking now. Please test it out.

johnbarclay’s picture

Status: Needs review » Fixed

Automatically closed -- issue fixed for 2 weeks with no activity.