Python3-LDAP 未返回预期结果

标签 python database curl python-3.x ldap

我正在使用 Python 3 LDAP 库 here .我不理解它关于“<=”运算符的行为。

我的范围是 uidNumber我需要测试特定值。我将范围分成几 block ,这样我就可以并行化每个部分。因此,查询的过滤器如下所示:

(&(uid=MY_UID)(&(uidNumber>=chunk_start)(uidNumber<=chunk_end)))

uidNumberuid 相关联我正在搜索介于 chunk_start 之间和 chunk_end .然而。在 ldap3.Connection 上运行上面的查询对象不返回任何结果。具体来说,我回来了:

[{'description': 'success',
  'dn': '',
  'message': '',
  'referrals': None,
  'result': 0,
  'type': 'searchResDone'}]

通过 curl 运行相同的查询产生了正确的结果,所以我在 ldap3 中进行了更多探索.我发现使用 >= 的查询运算符按预期工作,但与 <= 无关运算符(operator)曾经产生过任何结果。搜索 uidNumber和一个 uid产生以下内容:

In [175]: res = c.search('######' 
                '(&(uid=######)(uidNumber<=#######))', 
                 ldap3.SEARCH_SCOPE_WHOLE_SUBTREE, 
                 attributes=['objectClass', 'displayName'])

In [176]: c.getResponse(res)
Out[176]: 
[{'description': 'success',
  'dn': '',
  'message': '',
  'referrals': None,
  'result': 0,
  'type': 'searchResDone'}]

切换 <=对于 >=并离开 uidNumber在查询中同样会产生正确的结果。

我还注意到,如果我删除 uid参数,getResult返回 None ,而不是没有结果的列表。

这里出了什么问题?

编辑:

在架构中搜索“uidNumber”会产生以下结果:

attributeTypes: ( 1.3.6.1.1.1.1.0 NAME 'uidNumber' DESC 'Standard LDAP attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'RFC 2307' )
objectClasses: ( 1.3.6.1.1.1.2.0 NAME 'posixAccount' DESC 'Standard LDAP objectclass' SUP top AUXILIARY MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory ) MAY ( userPassword $ loginShell $ gecos $ description ) X-ORIGIN 'RFC 2307' )

反过来,查找 RFC 2307 是这样说的:

( nisSchema.1.0 NAME 'uidNumber'
          DESC 'An integer uniquely identifying a user in an
                administrative domain'
          EQUALITY integerMatch SYNTAX 'INTEGER' SINGLE-VALUE )

EQUALITY integerMatch line 表示不支持下单? curl 是侥幸吗是否返回正确的结果?

最佳答案

我是 python3-ldap 库的作者。你是对的,在处理 <= 运算符时库中有一个错误。

我已经在即将发布的 0.8.0 版本的 python3-ldap 中修复了它。

再见, 乔瓦尼

关于Python3-LDAP 未返回预期结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20767254/

相关文章:

python - Scipy `fmin_cg` 参数与我的函数参数不匹配

php - 创建表时出错 : No database selected

java - SQLite 数据库没有被创建并且没有错误出现

ios - Swift 中的 cURL 等价物 - iOS

Windows 上的 PHP/cURL 安装 : "The specified module could not be found."

python - Django 序列化器更新全部

python - Yaml 转储程序从 None 值输出空白而不是 null。如何让它输出 null 呢?

python - AWS使用Lambda将文件从S3存储桶下载到Windows本地目录

mysql - 需要使用不同条件从表的列中的单行中进行多次 id 计数

PHP CURL 发送 POST 到 Django 应用程序问题