I can't get authentication working.

I configured ldap_user to create drupal users when logging in.

When i try to login using a wrong password it says password incorrect.

When i try to login unsing the correct password i get the following error message:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xB5)\x95A\x8D\x02...' for column 'ldap_user_puid' at row 1: INSERT INTO {users_field_data} (uid, langcode, preferred_langcode, preferred_admin_langcode, name, pass, mail, timezone, status, created, changed, access, login, init, default_langcode, ldap_user_puid_sid, ldap_user_puid, ldap_user_puid_property, ldap_user_current_dn, ldap_user_last_checked, ldap_user_ldap_exclude) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20); Array ( [:db_insert_placeholder_0] => 99 [:db_insert_placeholder_1] => de [:db_insert_placeholder_2] => de [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => bachhubermax [:db_insert_placeholder_5] => $S$EpB8VV2rOjHyuj.ctX2HVo4AheOQKjT4HV8y/i1v0.pQ0U1xR0ju [:db_insert_placeholder_6] => user@example.com [:db_insert_placeholder_7] => Europe/Berlin [:db_insert_placeholder_8] => 1 [:db_insert_placeholder_9] => 1498828185 [:db_insert_placeholder_10] => 1498828185 [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => 0 [:db_insert_placeholder_13] => user@example.com [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => ad [:db_insert_placeholder_16] => X51�)�A�!�>,+B [:db_insert_placeholder_17] => objectGUID [:db_insert_placeholder_18] => CN=Maximilian Bachhuber,OU=showroomuser,DC=showroom,DC=local [:db_insert_placeholder_19] => 1498828186 [:db_insert_placeholder_20] => ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 777 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Seems like the guid mapping (which was automatically set by ldap_authentication module) is binary and cannot be saved to the database.

I can't toggle on conversion from binary in the ldap_user configuration because it is locked by ldap_authentication module.

The active directory field i am using for puid, configured in ldap_server, is "objectGUID".

A similar issue existed in Drupal 7 version of this module: https://www.drupal.org/node/1870630

CommentFileSizeAuthor
#8 ldap-settings2.PNG63.95 KBAnybody
#7 ldap-settings.PNG15.32 KBAnybody
#6 ldap-settings.PNG15.32 KBAnybody
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bahuma20 created an issue. See original summary.

bahuma20’s picture

A workaround is using objectSID instead of objectGUID as the puid in ldap_server configuration.

bahuma20’s picture

Status: Active » Closed (works as designed)

Stupid me... Just saw the checkbox "Does the Persistent and Unique User ID Attribute hold a binary value?" on the ldap_servers configuration.

Maybe we can catch this error and show a better error message...

grahl’s picture

Title: Ldap Authentication: using objectGUID as PUID fails without binary atribute - active directory » Catch binary puid misconfiguration if incorrectly set by user
Component: Code » User interface
Category: Bug report » Task
Priority: Major » Minor
Status: Closed (works as designed) » Postponed

Hi

Glad you got it working again.

I've reopened the issue per your comment that we should ideally catch this. I'm hesitant to just check for the non printable characters or null bytes or try encoding detections, since that could introduce subtle parsing bugs. However, if someone knows of a robust solution for this, I'd be open to it. Thus I've set it to postponed for now.

The only other thing I can think of would be to present a warning for the most common known binary ID attributes.

grahl’s picture

Version: 8.x-3.x-dev » 8.x-4.x-dev
Anybody’s picture

Status: Postponed » Active
FileSize
15.32 KB

Hi all,

I just ran into the same error, but in my case the binary option is set:
ldap settings

The error message is:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xD07\\xD91\xF8...' for column 'ldap_user_puid' at row 1: INSERT INTO {users_field_data} (uid, langcode, preferred_langcode, preferred_admin_langcode, name, pass, mail, timezone, status, created, changed, access, login, init, default_langcode, ldap_user_puid_sid, ldap_user_puid, ldap_user_puid_property, ldap_user_current_dn, ldap_user_last_checked, ldap_user_ldap_exclude) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15, :db_insert_placeholder_16, :db_insert_placeholder_17, :db_insert_placeholder_18, :db_insert_placeholder_19, :db_insert_placeholder_20); Array ( [:db_insert_placeholder_0] => 49 [:db_insert_placeholder_1] => de [:db_insert_placeholder_2] => de [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => xxx [:db_insert_placeholder_5] => xxx [:db_insert_placeholder_6] => xxx [:db_insert_placeholder_7] => Europe/Berlin [:db_insert_placeholder_8] => 1 [:db_insert_placeholder_9] => 1610708037 [:db_insert_placeholder_10] => 1610708037 [:db_insert_placeholder_11] => 0 [:db_insert_placeholder_12] => 0 [:db_insert_placeholder_13] => xxx [:db_insert_placeholder_14] => 1 [:db_insert_placeholder_15] => xxx [:db_insert_placeholder_16] => *�7\�1�B�;+l [:db_insert_placeholder_17] => objectsid [:db_insert_placeholder_18] => xxx [:db_insert_placeholder_19] => 1610708038 [:db_insert_placeholder_20] => ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->saveToSharedTables() (Zeile 1047 in /core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

I'm posting into this issue to find out if @bahuma20 was able to solve the error by checking the checkbox in 8.x-4.x as it was also his initial problem.

Regarding the warning I agree it would make sense to catch this and throw a detailed error.
I think this discussion is helpful, especially the reference to the Symfony implementation, which I guess is a good reference!
https://stackoverflow.com/questions/25343508/detect-if-string-is-binary

Anybody’s picture

FileSize
15.32 KB

Great ... it seems I did the same thing wrong as @bahuma20. As you can see from the screenshot above I thought the option in the SERVER SETTINGS was the relevant one here, but that's wrong. Like @bahuma20 I didn't see the other option in the Drupal Mapping list:

ldap settings

So now there are two blind people... and based on my wrong assumption I'd suggest the following:
- Check values for binaries like written above to prevent such errors, see #6 for ways
- Auto-check binary checkbox in code in the Drupal Mapping overview if the field is set to be binary in the server settings - I think this will prevent many users from our mistake

Anybody’s picture

FileSize
63.95 KB
kwfinken’s picture

Since this behavior is different than the drupal 7 version of the module and is not an intuitive change, it would be a good idea to add a HIGHLIGHTED note in the server setup indicating what needs to be done in the Drupal Mappings.

bluegeek9’s picture

Status: Active » Closed (outdated)