Trying to upgrade to 8.4 from 8.3 I am unable to set the LDAP Server Type to Active Directory.

When saving the configuration I get the message: Binding issues, please see log. (included below.)

Returning to the Configuration page the LDAP Server Type has reverted back to Default LDAP

Warning: ldap_connect(): Could not create session handle: Bad parameter to an ldap routine in Symfony\Component\Ldap\Adapter\ExtLdap\Connection->connect() (line 132 of /var/www/html/d8/vendor/grahl/ldap/Adapter/ExtLdap/Connection.php)
#0 /var/www/html/d8/web/core/includes/bootstrap.inc(600): _drupal_error_handler_real(2, 'ldap_connect():...', '/var/www/html/d...', 132, Array)
#1 [internal function]: _drupal_error_handler(2, 'ldap_connect():...', '/var/www/html/d...', 132, Array)
#2 /var/www/html/d8/vendor/grahl/ldap/Adapter/ExtLdap/Connection.php(132): ldap_connect('ldap://ldaps://...')
#3 /var/www/html/d8/vendor/grahl/ldap/Adapter/ExtLdap/Connection.php(57): Symfony\Component\Ldap\Adapter\ExtLdap\Connection->connect()
#4 /var/www/html/d8/vendor/grahl/ldap/Ldap.php(40): Symfony\Component\Ldap\Adapter\ExtLdap\Connection->bind('Web Master', 'xxxxxxxxxx')
#5 /var/www/html/d8/web/modules/contrib/ldap/ldap_servers/src/LdapBridge.php(138): Symfony\Component\Ldap\Ldap->bind('Web Master', 'xxxxxxxxxx')
#6 /var/www/html/d8/web/modules/contrib/ldap/ldap_servers/src/ServerListBuilder.php(89): Drupal\ldap_servers\LdapBridge->bind()
#7 /var/www/html/d8/web/modules/contrib/ldap/ldap_servers/src/ServerListBuilder.php(54): Drupal\ldap_servers\ServerListBuilder->checkStatus(Object(Drupal\ldap_servers\Entity\Server))
#8 /var/www/html/d8/web/core/lib/Drupal/Core/Entity/EntityListBuilder.php(235): Drupal\ldap_servers\ServerListBuilder->buildRow(Object(Drupal\ldap_servers\Entity\Server))
#9 /var/www/html/d8/web/core/lib/Drupal/Core/Entity/Controller/EntityListController.php(23): Drupal\Core\Entity\EntityListBuilder->render()
#10 [internal function]: Drupal\Core\Entity\Controller\EntityListController->listing('ldap_server')
#11 /var/www/html/d8/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#12 /var/www/html/d8/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /var/www/html/d8/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#14 /var/www/html/d8/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#15 /var/www/html/d8/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /var/www/html/d8/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#17 /var/www/html/d8/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/d8/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/d8/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/d8/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/d8/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/html/d8/web/modules/contrib/devel/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(38): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/html/d8/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/html/d8/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/html/d8/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /var/www/html/d8/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#27 {main}

And:

LDAP bind failure: Could not set value "3" for option "protocol_version"..

.

Issue fork ldap-3151284

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jon.lund created an issue. See original summary.

grahl’s picture

Issue summary: View changes

  • grahl committed c5b9ac4 on 8.x-4.x
    Issue #3151284: Can not set LDAP Server Type to Active Directory (fix...
grahl’s picture

Status: Active » Postponed (maintainer needs more info)

Hi

Thanks for the bug report, not being able to set type AD is unrelated to your problem, though thank you for reporting it, the commit above fixes that.

Would you be able to share your anonymized server configuration yaml file? This helps understand what could be causing issues in the connection string, right now it simply looks like it was given incorrect data.

Can you also elaborate from which beta in 3.x you came and if you could apply the updates (updb) without issue?

jon.lund’s picture

I had reverted back to 8.3.x Beta 7.

  • I made a copy of that site.
  • Changed the the composer.json to require :^4.0 vs 3.0
  • Ran composer update
  • on the site ran update.php
  • 6 db updates were performed
  • navigated to LDAP server configuration (Binding issues, please see log.)
  • edited all fields to the appropriate values and saved. (Binding issues, please see log.)
  • The same messages that I had previously sent were present.

I would be happy to send any files you would like. What is the name of the file? I looked through all .yml files in ldap_servers and ldap_authentication and did not see anything that would need to be anonymized prior to sending.

nixar’s picture

I have the same issue after patching. I checked the config as stored in the DB and it shows as ldaps://xxx but it seems that
#2 /var/www/html/d8/vendor/grahl/ldap/Adapter/ExtLdap/Connection.php(132): ldap_connect('ldap://ldaps://...')
does receive the address prepended by "ldap://" or at least the problem is with
$this->connection = ldap_connect($this->config['connection_string']);

I dug around a bit and found that /var/www/html/d8/vendor/grahl/ldap/Adapter/AbstractConnection.php does something to set this connection_string property at line 48 where it does set the protocol depending on the encryption.

What I tried next is to replace in the original file (/vendor/grahl/ldap/Adapter/ExtLdap/Connection.php line 132)
this->connection = ldap_connect($this->config['connection_string']);
with
$this->connection = ldap_connect($this->config['host'], $this->config['port']);

while I keep the protocol in my server config and it seems to work now.

This is in no way a fix but I hope it helps and save some time to the people with the knowledge to patch.

jon.lund’s picture

#6 above worked for me.

I did have to re-enter all of the fields on the LDAP_Server config page.
But all other settings, User Settings, Drupal mappings, and Authentication were set from the upgrade from version ^3.0 (I do not use LDAP mappings.)

I am not sure if this is an appropriate fix. Perhaps this issue is upstream when setting the 'connection_string'. I will be watching this issue.

I appreciate and could not live without this module.

Thank you, grahl

grahl’s picture

Assigned: Unassigned » grahl
Status: Postponed (maintainer needs more info) » Active

Thanks for the feedback, that helps!

At the very least it makes a good test case so that we can test for the protocol and throw an error if we pass something incorrect along to symfony/ldap.

I'll look into maybe creating an update hook to clean that up if that's an option without degrading connection preferences (namely https).

micahw156’s picture

I just started testing with the latest dev release (commit 5a79126, contains c5b9ac4 above) and I'm getting the same error whether I use Default LDAP or Novell for server type, with or without the ldaps:// prefix in the field. This is on a fresh D9 install so nothing was copied from 8.x.

The connection works (as Novell type) on 389 with Start-TLS (which my network admin is trying to abolish.) I'll be watching this issue, too, but at least it's not a show-stopper for me right now.

Edit to confirm that I'm able to connect with ldaps:// using ldapsearch from command line from the same web server, and sites using 8.x-3.x are also working with ldaps:// from this server.

tenken’s picture

I am using version:
"drupal/ldap": "4.x-dev#958f3aa79902bb9bb0cd62431b2ac9c012e292c1",

And for OpenLDAP I also need to create a localized composer patch file that applies #6 to the -dev release of LDAP so that connections are succesful. Otherwise the Bind fails.

binnythomas’s picture

I can confirm I am facing the same issue in my setup as well.

I can connect to the LDAP server (OpenLDAP) in the command line using

ldapwhoami -H ldap://localhost:389 -x

However entering the same in the LDAP module server settings causing the Binding issues check error log message.

carles.zapater’s picture

Hi, I can confirm I am facing the same issue in my setup as well.

Error logs:

Warning: ldap_connect(): Could not create session handle: Bad parameter to an ldap routine in Symfony\Component\Ldap\Adapter\ExtLdap\Connection->connect() (line 132 of /var/www/html/vendor/grahl/ldap/Adapter/ExtLdap/Connection.php)

LDAP bind failure: Could not set value "3" for option "protocol_version"..

carles.zapater’s picture

#0 /var/www/html/web/core/includes/bootstrap.inc(301): _drupal_error_handler_real(2, 'ldap_connect():...', '/var/www/html/v...', 132, Array)
#1 [internal function]: _drupal_error_handler(2, 'ldap_connect():...', '/var/www/html/v...', 132, Array)
#2 /var/www/html/vendor/grahl/ldap/Adapter/ExtLdap/Connection.php(132): ldap_connect('ldap://ldaps://...')

binnythomas’s picture

In my setup I was able to solve the problem by simply removing the ldap protocol from the ldap url. So instead of ldap://domain.xyz, I simply added domain.xyz. This should have been obvious to me but I guess I overlooked that.

carles.zapater’s picture

Hi,

@binnythomas It only works if the protocol is ldap; with ldaps it doesn't work

nruest’s picture

I'm running into this issue as well on 8.x-4.0-alpha3, and with ldaps. The fix in #6 resolved the issue for me.

zipymonkey’s picture

StatusFileSize
new560 bytes

I created a patch for grapl/ldap based on @nixar comment (#6). I am apply this during composer install/update. Might be helpful for someone.

{
  "patches": {
    "grahl/ldap": {
      "Patch to allow ldaps (see https://www.drupal.org/project/ldap/issues/3151284)": "patches/ldap/grahl-ldap-patch-for-3151284.patch"
    }
  }
}
grahl’s picture

Version: 8.x-4.0-alpha2 » 8.x-4.x-dev
Component: User interface » Code
Status: Active » Needs review
StatusFileSize
new107.89 KB

Hey everyone

Thanks for the input above, that helped nail down the problem more quickly.

So since grahl/ldap is just a workaround around the d.o CI and really symfony/ldap. We don't want to patch over there, since that won't get in anyway.

Previously we had the split option of STARTTLS vs connection string with ldaps and port definition before this library was the base. Since symfony/ldap can handle abstracting that out for us it makes sense to align our server config to it.

The attached MR does the following:
- Add encryption field, remove tls field
- Update hook to derive sensible default for it
- Fix the server hostname description and filter out the ldap(s):// prefix.

That retains the custom port and adds ldaps where appropriate:
custom ldaps

Test feedback is appreciated, would be especially great if people could give a positive feedback for each method (none, ssl, tls).

grahl’s picture

Assigned: grahl » Unassigned
winstan’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm the changes work for us. Tested all methods: (none, ssl, tls). We're using 389-ds with support for all three.

winstan’s picture

I can confirm that all methods work (none, ssl, tls). Confirmed using a 389-ds directory server.

joelpittet’s picture

Strange I could have swore I saw @winstan (on a video call as he's a new contributor and works with me) mark the status as RTBC... oh well.

jon.lund’s picture

I can confirm that this latest patch is working with Active Directory server using ldaps://example.com in Drupal 9.1.0 and ldap 4.x-dev.

Thank you for all of your work!

micahw156’s picture

I can confirm testing with STARTTLS and SSL methods against our Novell (Microfocus NetIQ eDirectory) servers on Drupal 9.1.0.

Thanks for the update!

  • grahl committed 61b14e6 on 8.x-4.x
    Issue #3151284 by zipymonkey, grahl, nixar: Can not set LDAP Server Type...
grahl’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, thanks so much for the detailed test feedback everyone!

Status: Fixed » Closed (fixed)

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

couloir007’s picture

If this issue is fixed why is the 4.x version still break? I applied this patch and it works, but it seem like it shouldn't be broke anymore to begin with.

Perhaps 'drupal/ldap:4.x-dev@dev' fixes it which if it does I can't install this because of this:

Your requirements could not be resolved to an installable set of packages.

Problem 1
- drupal/ldap_servers 4.0.0-beta3 requires drupal/ldap 4.0.0-beta3 -> satisfiable by drupal/ldap[4.0.0-beta3] but these conflict with your requirements or minimum-stability.
- drupal/ldap_servers 4.0.0-beta3 requires drupal/ldap 4.0.0-beta3 -> satisfiable by drupal/ldap[4.0.0-beta3] but these conflict with your requirements or minimum-stability.
- drupal/ldap_servers 4.0.0-beta3 requires drupal/ldap 4.0.0-beta3 -> satisfiable by drupal/ldap[4.0.0-beta3] but these conflict with your requirements or minimum-stability.
- Installation request for drupal/ldap_servers (locked at 4.0.0-beta3) -> satisfiable by drupal/ldap_servers[4.0.0-beta3].

My minimum stability is dev, it seems like ldap_servers has requirements that conflict.

couloir007’s picture

Turns out my issue is that vendor/composer/installed.json won't allow it. Deleting the entry solves this, but is annoying none-the-less. Another issue we are having is this:

// Remove prefix to avoid user error.
$this->entity->set('address', preg_replace('#^ldaps?://#', '', $form_state->getValue('address')));

The only thing this avoids is connecting to our servers. If we need to connect through ldaps why remove it? Commenting it out solves it for us.

Thanks!

grahl’s picture

@couloir007 Regarding composer: Due to the meta-package you might need to list all sub-modules when upgrading, the easiest way for you might be to update everything with "composer update" if you don't want to explicitly list that. It's a quirk of how Drupal packages are present in packagist.

Regarding removal of the prefix: Please see the "Encryption" dropdown on the server configuration. If you have set that correctly and can still not connect, please open a new issue, I presume this is a misconfiguration on your side based on the test feedback we had from other users.

couloir007’s picture

Under Server address I put ldaps://si-xxxx.xx.xxx.si.edu and choose SSL (i.e. the ldaps:// protocol). When I save the form only si-xxxx.xx.xxx.si.edu shows because the ldaps:// is stripped. Even though I selected the SSL above, it fails to connect. When I comment out the line that strips the ldaps:// and it saves as ldaps://si-xxxx.xx.xxx.si.edu it has no issue connecting to our servers.

grahl’s picture

This is a closed issue. Reiterating my previous statement: "If you have set that correctly and can still not connect, please open a new issue".