|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-08-04 09:35 UTC] justinasu at gmail dot com
Description:
------------
<ldapserver> and <base dn> in test script should be substituted with some ldap server that you have access to and you need to have read permission to usnchanged attribute.
when searching for entries by usnchanged which is a Microsoft proposed way of polling for changes, the test script returns 0 results. But if you run the same filter query in Active Directory explorer or some other tool i get many results - couple of thousand.
if the value is smaller lets say (usnchanged>=261605367) i get expected results.
i suspect that somewhere in LDAP php internals the value gets interpreted as 32bit integer and since it's max is 4,294,967,295, the query with higher values never returns any results. usnchanged field is 8bit INTERGER (BIGINT) in Active Directory.
tried on linux Centos 6.8 x64 the result is the same.
Test script:
---------------
$res = ldap_connect('ldap://<ldapserver>');
ldap_set_option($res, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind($res)
$response = ldap_search($res, '<base dn>', '(usnchanged>=4261605367)');
$result = ldap_get_entries($res, $response);
var_dump($result);
Expected result:
----------------
array with count > 0
Actual result:
--------------
array with count === 0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 12:00:01 2025 UTC |
yes, ldapsearch returns results as expected: ldapsearch -H 'ldaps://<ldapserver>' -D 'username@domain' -b '<base dn>' -W -s sub "(usnchanged>=4261605367)" cn sn # search result search: 2 result: 4 Size limit exceeded # numResponses: 1004 # numEntries: 1000 # numReferences: 3 ldapsearch: @(#) $OpenLDAP: ldapsearch 2.4.40 (May 10 2016 23:31:28) $ mockbuild@worker1.bsys.centos.org:/builddir/build/BUILD/openldap-2.4.40/openldap-2.4.40/build-clients/clients/tools (LDAP library: OpenLDAP 20440) php is 64bit: var_dump(PHP_INT_SIZE); int(8) this bug is reproduced all the way up to php v5.5. This is the oldest version i have tried.ldd /usr/lib64/php/modules/ldap.so linux-vdso.so.1 => (0x00007fffe35b3000) libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x00007fb9a99dd000) libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x00007fb9a978c000) liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x00007fb9a957c000) libc.so.6 => /lib64/libc.so.6 (0x00007fb9a91e8000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fb9a8fe4000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00007fb9a8dc9000) libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fb9a8b92000) libssl3.so => /usr/lib64/libssl3.so (0x00007fb9a894f000) libsmime3.so => /usr/lib64/libsmime3.so (0x00007fb9a8721000) libnss3.so => /usr/lib64/libnss3.so (0x00007fb9a83e1000) libnssutil3.so => /usr/lib64/libnssutil3.so (0x00007fb9a81b5000) libplds4.so => /lib64/libplds4.so (0x00007fb9a7fb0000) libplc4.so => /lib64/libplc4.so (0x00007fb9a7dab000) libnspr4.so => /lib64/libnspr4.so (0x00007fb9a7b6d000) /lib64/ld-linux-x86-64.so.2 (0x0000003a92200000) libfreebl3.so => /lib64/libfreebl3.so (0x00007fb9a7969000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb9a774c000) libz.so.1 => /lib64/libz.so.1 (0x00007fb9a7536000) librt.so.1 => /lib64/librt.so.1 (0x00007fb9a732d000) file /lib64/libldap-2.4.so.2 /lib64/libldap-2.4.so.2: symbolic link to `libldap-2.4.so.2.10.3' here you go :)And a further question: Can you alter your testscript like this and post the results? $res = ldap_connect('ldap://<ldapserver>'); ldap_set_option($res, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_bind($res) $response = ldap_search($res, '<base dn>', '(usnchanged>=4261605367)'); var_Dump($response); var_Dump(ldap_count_entries($res)); $result = ldap_get_entries($res, $response); var_Dump(ldap_error($res)); var_dump($result); Thanks!file /lib64/libldap-2.4.so.2.10.3 /lib64/libldap-2.4.so.2.10.3: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped resource(99) of type (ldap result) int(0) string(7) "Success" array(1) { ["count"]=> int(0) }