My general use case:
- An attendant is logged into the site, running an 'event'.
- The attendant checks in / enrolls a guest by having them 'log in'.
- The guest is authenticated against corporate LDAP.
- A login event should be simulated and LDAP data/roles should synced back to the authenticated guest.
- ... additional business logic ...
So, in the form's validate function, I'm making use of ldap functions as follows:
$enroll_user = ldap_authentication_user_login_authenticate_validate(NULL, $form_state, TRUE);
...
ldap_authorizations_user_authorizations($enroll_user, 'test_query_set', 'drupal_role', 'logon');
The full error when attempting to enroll a user not in the DB (note: the error does not appear if the user had been authenticated before):
Notice: Object of class stdClass could not be converted to int in drupal_write_record() (line 7123 of .../htdocs/includes/common.inc).
Notice: Undefined index: ldap_authorizations in _ldap_authorizations_user_authorizations() (line 294 of .../htdocs/sites/all/modules/ldap/ldap_authorization/ldap_authorization.inc).
Looking at line 294 in ldap_authorization.inc:
$data = property_exists($user, 'data') ? $user->data['ldap_authorizations'][$consumer->consumerType] : array();
Can I safely rewrite it?
$data = (property_exists($user, 'data') && isset($user->data['ldap_authorizations'])) ? $user->data['ldap_authorizations'][$consumer->consumerType] : array();
If so, I can provide a patch. And feel free to let me know if I should use the LDAP functions differently, given my use case. Thanks.
Comments
Comment #1
thisisjoe commentedSorry, hit "Save" before actually testing it.
After the change, I do still receive the following error:
Please advise, thanks.
Comment #2
thisisjoe commentedComment #3
thisisjoe commentedComment #4
johnbarclay commentedPlease test and file bugs against 7.x-2.x-dev.
Comment #5
johnbarclay commentedComment #6
grahlHi
I know it's a while ago but did you end up using this workaround and could you provide a patch to the current codebase?
Comment #7
kotoponus commentedI get the same error as comment #1 immediately after logging in using LDAP authentication.
The LDAP successfully authenticates and creates a user record pulling correct role association etc. I have placed a random echo:
just at the line in the error.
I got the following:
Since I am echoing presumably before the completion of the bootstrapping, the page does not complete and ends at above.
We can see that there are string and NULL in this integer conversion. In respect with NULL, since 0, null and false can be the same in their loose comparison (http://php.net/manual/en/types.comparisons.php), I sort of suspect that uid conversion from string is more suspicious.
Now as I said, as for me, it creates a user record ok from LDAP authentication and pulls the right info although it returns an error. The error is only a Notice after all, it is not really an serious error per se although it is annoying.
The immediate solution is either to suppress the error display level (as per http://php.net/manual/en/function.error-reporting.php) somewhere appropriate or to suppress producing the error using @ in line 7340 just before "@(int)".
Now this is LDAP module issue support, so I am not sure if you can do anything about values you pass to drupal_write_record() function which is where this error message is produced. I mean, even my above echo ends up being nothing to do with this NOTICE error, it probably helps to check the values as it is to do with a data type conversion issue. I have not been able to dpm or var_dump successfully as I trying to debug in hurry as it seems to create a "serious" code integrity issue so that it only returns HTTP 500 internal server error. (I could be spending more time I suppose...)
Just for your info, I have D7.54, Postgres 9.4.6, PHP 7.0.5 and on OpenSuse:
me@myserver:~> lsb_release -a
LSB Version: n/a
Distributor ID: SUSE LINUX
Description: openSUSE Leap 42.1 (x86_64)
Release: 42.1
Codename: n/a
Comment #8
kotoponus commentedFor now this will suffice:
$fields[$field] = @(int) $fields[$field];Although I should not go on like this for a long time in the core codes.
Comment #9
kotoponus commentedHum, seeing issue contributions to do with drupal_write_record and LDAP module, I came to this, which rings a bell:
https://www.drupal.org/node/2123773
as I also have thumbnailPhoto mapped against Drupal's "Property: Picture" attribute and indeed I see no photo showing up from LDAP. I may give it a go...
Comment #10
kotoponus commentedBingo, my issue resolved and I have got no notice message either. @thisisjoe, can this be a solution to your issue???
Comment #11
Saoirse1916 commentedJust a head's up, the change in the OP now works to suppress the error against 7x.-2.2.
Comment #12
grahlAh, fun. Turns out how userPictureFromLdapEntry() handles images is entirely broken.
Thanks for the input.
Comment #13
grahlI believe that the changes I've made to the picture import should have fixed this.
Please reopen of you still can reproduce this with current dev.