首页 > 解决方案 > 为什么 Perl Net::LDAP 与 GSSAPI SASL 绑定在 Debian buster 上连接到错误的 sasl_ssf?

问题描述

我有一个 Perl 脚本,可以使用带有 GSSAPI 绑定的 Net::LDAP 从 OpenLDAP 实例中读取。该脚本在 Debian stretch 上运行良好,但在 Debian buster 上失败。

请注意,在两台服务器上,运行的 Perl 代码底部的行ldapsearch会产生相同的正确结果,因此我确信两台服务器上的 Kerberos 票证缓存都是正确的。

查看 OpenLDAP 日志,我看到 ldapsearch 运行显示了强度因子sasl_ssf=256 ssf=256,而 Net::LDAP 绑定显示了强度因子sasl_ssf=1 ssf=256。由于 Net::LDAP 绑定使用的是 Kerberos,所以sasl_ssf应该是 56,而不是 1。

关于为什么 Net::LDAP 绑定连接错误的任何建议sasl_ssf

use strict;
use warnings;
use Authen::SASL;
use Net::LDAP;
use Data::Dumper;

my $server_name = 'ldap.example.com';
$ENV{'KRB5CCNAME'} = '/tmp/krb.tkt';

my $ld = Net::LDAP->new($server_name, version => '3');
$ld->start_tls(verify => 'require');

if (!$ld or $ld == -1) {
    die "Could not connect to directory server $server_name";
}

my $SASL = Authen::SASL->new('GSSAPI');
my $status = $ld->bind(sasl => $SASL);

if ($status->code) {
    die  'Bind error: (' . $status->error_name . ') ' . $status->error_text;
}

my $base   = 'dc=example,dc=com';
my $filter = '(uid=johndoe)';
my @attrs  = ('uid', 'sn');
$status = $ld->search(
    base    => 'dc=example,dc=com',
    filter  => $filter,
    attrs   => \@attrs,
    ) ;

my @entries = $status->all_entries;
# This results in nothing (but should result in the same data as the ldapsearch below):                                                                                                          
warn Dumper @entries ;

my $attrs = join(' ', @attrs) ;
my $cmd = "ldapsearch -LLL -h $server_name -b $base '$filter' $attrs";
# This gives the correct result:                                                                                                     
warn `$cmd`;

标签: perlopenldapsaslgssapidebian-buster

解决方案


推荐阅读