Discussion:
Replacement for ldap_sort_entries
Côme BERNIGAUD
2015-06-24 13:27:05 UTC
Permalink
Hello,

I’m trying to get rid of the -DLDAP_DEPRECATED=1 option when building the php-ldap module.
For other functions it went fine but the php function ldap_sort is using ldap_sort_entries which is deprecated with no replacement.
As I can’t remove ldap_sort from PHP API, I need to find a way to replace this function call if I want to get rid of deprecated calls.

I tried copy/pasting the function code to see if I could built it myself but then it complains about incomplete type for LDAPMessage, which seems internal to libldap.

Any idea about a replacement for this function?

CÃŽme
Michael Ströder
2015-06-24 14:19:03 UTC
Permalink
Post by Côme BERNIGAUD
I’m trying to get rid of the -DLDAP_DEPRECATED=1 option when building the
php-ldap module.
For other functions it went fine but the php function ldap_sort is using
ldap_sort_entries which is deprecated with no replacement.
As I can’t remove ldap_sort from PHP API, I need to find a way to replace this
function call if I want to get rid of deprecated calls.
How about reimplementing it in PHP?

Ciao, Michael.
Côme BERNIGAUD
2015-06-24 14:37:34 UTC
Permalink
Post by Michael Ströder
Post by Côme BERNIGAUD
I’m trying to get rid of the -DLDAP_DEPRECATED=1 option when building the
php-ldap module.
For other functions it went fine but the php function ldap_sort is using
ldap_sort_entries which is deprecated with no replacement.
As I can’t remove ldap_sort from PHP API, I need to find a way to replace this
function call if I want to get rid of deprecated calls.
How about reimplementing it in PHP?
Not sure if you mean in the PHP language or in the PHP binary. The first one is not possible if I’m not mistaking, the second one is indeed what I’d like to do but not sure how.

I need the API to stay exactly the same.
ldap_sort is called after the call to ldap_search and before the call to ldap_get_entries.
So it needs to work on the result themselves so that they are sorted when the next ldap accessing results function is called.
That’s why it needs to be done in the C code. And that’s why it needs access to the LDAPMessage struct which is internal to OpenLDAP as far as I understood things.

CÃŽme
Pierangelo Masarati
2015-06-24 15:26:48 UTC
Permalink
Content preview: On 24/06/2015 16:37, Côme BERNIGAUD wrote: > On 2015-06-24
16:19, Michael Ströder wrote: >> Côme BERNIGAUD wrote: >>> I’m trying
to get rid of the -DLDAP_DEPRECATED=1 option when >>> building the >>> php-ldap
module. >>> For other functions it went fine but the php function ldap_sort
is >>> using >>> ldap_sort_entries which is deprecated with no replacement.
Post by Côme BERNIGAUD
Post by Michael Ströder
As I can’t remove ldap_sort from PHP API, I need to find a way to >>>
replace this >>> function call if I want to get rid of deprecated calls.
Post by Côme BERNIGAUD
Post by Michael Ströder
How about reimplementing it in PHP? > > Not sure if you mean in the
PHP language or in the PHP binary. The > first one is not possible if I’m
not mistaking, the second one is > indeed what I’d like to do but not sure
how. > > I need the API to stay exactly the same. > ldap_sort is called after
the call to ldap_search and before the call > to ldap_get_entries. > So it
needs to work on the result themselves so that they are sorted > when the
next ldap accessing results function is called. > That’s why it needs to
be done in the C code. And that’s why it needs > access to the LDAPMessage
struct which is internal to OpenLDAP as far > as I understood things. The
logic of that sorting is broken. Sorting by DN (or by value) requires the
knowledge of the syntax and matching rule(s) of the corresponding attributes.
First of all, the client is not supposed to know much about it. Second, a
wise implementation would normalize values (or DNs), then sort. An accurate
implementation of those functionalities based on the deprecated API would
be at least inefficient. It would be much wiser to do the sorting at the
client's side, after extracting data from the LDAP results. And the PHP interface
should deprecate those functions as well. [...]

Content analysis details: (-1.9 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL
was blocked. See
http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
for more information.
[157.56.112.62 listed in list.dnswl.org]
-0.0 SPF_HELO_PASS SPF: HELO matches SPF record
-0.0 SPF_PASS SPF: sender matches SPF record
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
X-BeenThere: openldap-***@openldap.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: OpenLDAP Technical Discussion list <openldap-technical.openldap.org>
List-Unsubscribe: <http://www.openldap.org/lists/mm/options/openldap-technical>,
<mailto:openldap-technical-***@openldap.org?subject=unsubscribe>
List-Archive: <http://www.openldap.org/lists/openldap-technical/>
List-Post: <mailto:openldap-***@openldap.org>
List-Help: <mailto:openldap-technical-***@openldap.org?subject=help>
List-Subscribe: <http://www.openldap.org/lists/mm/listinfo/openldap-technical>,
<mailto:openldap-technical-***@openldap.org?subject=subscribe>
Errors-To: openldap-technical-***@openldap.org
Sender: "openldap-technical" <openldap-technical-***@openldap.org>
X-Spam-Score: -1.9 (-)
X-Spam-Report: Spam detection software, running on the system "gauss.openldap.net", has
identified this incoming email as possible spam. The original message
has been attached to this so you can view it (if it isn't spam) or label
similar future email. If you have any questions, see
the administrator of that system for details.

Content preview: On 24/06/2015 16:37, Côme BERNIGAUD wrote: > On 2015-06-24
16:19, Michael Ströder wrote: >> Côme BERNIGAUD wrote: >>> I’m trying
to get rid of the -DLDAP_DEPRECATED=1 option when >>> building the >>> php-ldap
module. >>> For other functions it went fine but the php function ldap_sort
is >>> using >>> ldap_sort_entries which is deprecated with no replacement.
Post by Côme BERNIGAUD
Post by Michael Ströder
As I can’t remove ldap_sort from PHP API, I need to find a way to >>>
replace this >>> function call if I want to get rid of deprecated calls.
Post by Côme BERNIGAUD
Post by Michael Ströder
How about reimplementing it in PHP? > > Not sure if you mean in the
PHP language or in the PHP binary. The > first one is not possible if I’m
not mistaking, the second one is > indeed what I’d like to do but not sure
how. > > I need the API to stay exactly the same. > ldap_sort is called after
the call to ldap_search and before the call > to ldap_get_entries. > So it
needs to work on the result themselves so that they are sorted > when the
next ldap accessing results function is called. > That’s why it needs to
be done in the C code. And that’s why it needs > access to the LDAPMessage
struct which is internal to OpenLDAP as far > as I understood things. The
logic of that sorting is broken. Sorting by DN (or by value) requires the
knowledge of the syntax and matching rule(s) of the corresponding attributes.
First of all, the client is not supposed to know much about it. Second, a
wise implementation would normalize values (or DNs), then sort. An accurate
implementation of those functionalities based on the deprecated API would
be at least inefficient. It would be much wiser to do the sorting at the
client's side, after extracting data from the LDAP results. And the PHP interface
should deprecate those functions as well. [...]

Content analysis details: (-1.9 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL
was blocked. See
http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
for more information.
[157.56.112.62 listed in list.dnswl.org]
-0.0 SPF_HELO_PASS SPF: HELO matches SPF record
-0.0 SPF_PASS SPF: sender matches SPF record
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
Post by Côme BERNIGAUD
Post by Michael Ströder
I’m trying to get rid of the -DLDAP_DEPRECATED=1 option when
building the
php-ldap module.
For other functions it went fine but the php function ldap_sort is using
ldap_sort_entries which is deprecated with no replacement.
As I can’t remove ldap_sort from PHP API, I need to find a way to
replace this
function call if I want to get rid of deprecated calls.
How about reimplementing it in PHP?
Not sure if you mean in the PHP language or in the PHP binary. The
first one is not possible if I’m not mistaking, the second one is
indeed what I’d like to do but not sure how.
I need the API to stay exactly the same.
ldap_sort is called after the call to ldap_search and before the call to ldap_get_entries.
So it needs to work on the result themselves so that they are sorted
when the next ldap accessing results function is called.
That’s why it needs to be done in the C code. And that’s why it needs
access to the LDAPMessage struct which is internal to OpenLDAP as far
as I understood things.
The logic of that sorting is broken. Sorting by DN (or by value)
requires the knowledge of the syntax and matching rule(s) of the
corresponding attributes. First of all, the client is not supposed to
know much about it. Second, a wise implementation would normalize
values (or DNs), then sort. An accurate implementation of those
functionalities based on the deprecated API would be at least
inefficient. It would be much wiser to do the sorting at the client's
side, after extracting data from the LDAP results. And the PHP
interface should deprecate those functions as well.

p.
--
Pierangelo Masarati
Associate Professor
Dipartimento di Scienze e Tecnologie Aerospaziali
Politecnico di Milano
Côme BERNIGAUD
2015-06-24 16:00:46 UTC
Permalink
The logic of that sorting is broken. Sorting by DN (or by value) requires the knowledge of the syntax and matching rule(s) of the corresponding attributes. First of all, the client is not supposed to know much about it. Second, a wise implementation would normalize values (or DNs), then sort. An accurate implementation of those functionalities based on the deprecated API would be at least inefficient. It would be much wiser to do the sorting at the client's side, after extracting data from the LDAP results. And the PHP interface should deprecate those functions as well.
I do intend to deprecate this function but I can’t remove it right away so I’m searching for a solution allowing to remove the -DLDAP_DEPRECATED=1 without losing this sorting feature.
Loading...