When updating any value in an existing LDAP Authorization setup, there will be a new row created in the database table "ldap_authorization" with the new values. But the values from the first row are used only. When i edit the database manually and delete all rows but the first, everything works fine. Database is Postgres 9.1.2.

CommentFileSizeAuthor
#2 LDAP_Report-html.txt18.83 KBgeste
ldap_config.html_.zip2.43 KBsuperhenne

Comments

johnbarclay’s picture

Title: Authorization: Duplicate entry in db after updating configuration » LDAP Authorization: Duplicate entry in db after updating configuration
Assigned: Unassigned » johnbarclay
geste’s picture

StatusFileSize
new18.83 KB

I can reproduce this problem on a fresh install of D7.12 running MySQL 5.1.61 on Redhat 6.

I added LDAP 7.x-1.0-beta9 immediately after Drupal setup and enabled authentication and SSO without problems. SSO works great, even using NTLM auth type generically to get our Apache REMOTE_USER.

I then anabled LDAP Authorization and LDAP Authorization-Roles and created an authorization configuration but did not immediately enable it but saved it. Then once I fine-tuned some group|role filters I then checked "Enable this configuration" but the "Enabled" value was not saved. After multiple attempts I noticed 8-9 rows in ldap_authorization table which indeed had all of the changes I had attempted to save, but the "edit" operation would always retrieve the values from the first row and I concluded that the additional rows might be abnormal

So, I disabled the ldap_authorization/-roles modules and emptied the drupal_authorization table and re-enabled the ldap_auth/-roles modules. I then created a new ldap_authorization configuration and selected "Enable this configuration" immediately before save. The configuration was saved and works but subsequent changes to things like group|role filters were saved as new rows in the ldap_authorization table and were not being reference.

Hope this makes sense. Config file attached.

Jim

johnbarclay’s picture

Priority: Normal » Major

thanks. appreciate the details. I will get this right after I return from drupalcon. Patch would be appreciated, but I think its an easy fix since it can be replicated on mysq and postgres.

johnbarclay’s picture

do you have ctools module enabled? (It shouldn't need to be enabled)

johnbarclay’s picture

Status: Active » Postponed (maintainer needs more info)

And does the field "numeric_consumer_conf_id" exist in the ldap_authorization table? I suspect this has something to do with the code in the save method of LdapAuthorizationConsumerConfAdmin.class.php, but can't replicate it. If you disable ctools do you still have the same behavior?

I'll take another look at this after I get all the code I'm working on checked in; my install isn't close enough to a clean install to be useful here.

    if (module_exists('ctools')) {
      ctools_include('export');
      // Populate our object with ctool's properties
      $object = ctools_export_crud_new('ldap_authorization');
      foreach ($object as $property => $value) {
        if (!isset($values->$property)) {
          $values->$property = $value;
        }
      }
      $result = ctools_export_crud_save('ldap_authorization', $values);
    }
johnbarclay’s picture

Version: 7.x-1.0-beta7 » 7.x-1.x-dev
Status: Postponed (maintainer needs more info) » Needs review

Thanks for your patience on this one. I replicated the error and committed a fix for it in 7.x-1.0-dev. All this pain was from changing the "edit" button to say "save". The only change is below in case you want to avoid the latest dev version.

In LdapAuthorizationConsumerConfAdmin.class.php in the function populateFromDrupalForm

- $this->inDatabase = (drupal_strtolower($op) == 'edit');
+ $this->inDatabase = (drupal_strtolower($op) == 'edit' || drupal_strtolower($op) == 'save');
johnbarclay’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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