[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: [newbie] How to get struct ldap->ld_lberoptions from application?



At 06:24 AM 2/11/2005, Ames Andreas wrote:
>Hello,
>
>I'm wrapping some server-side controls related stuff in python.
>Therefore I want to be able to create variables of type BerElement
>without an LDAP* being available, such that control values can be
>"first class" objects in my application (without requiring an LDAP*
>context).
>
>Unfortunately then I can't use ber_allocate_with_options then and I
>have to go with 'ber_alloc_t'.  Currently I just specify LBER_USE_DER
>in every call to ber_alloc_t as ldapsearch.c does.

Good.  See draft-ietf-ldapext-ldap-c-api-xx.txt (in doc/drafts).

>But my impression
>is that it would be preferable to set ber->ber_options to the value of
>struct ldap's ld_lberoptions (which obviously is always available when
>the BerElement gets actually encoded by ldap_create_control, which is
>immediately before the coded value hits the wire in my case).
>
>Is this assumption correct?

No.  The general assumption around here is that programmers code
by examples set in draft-ietf-ldapext-ldap-c-api-xx.txt and
clients/tool/*.c.

I note that even libldap itself doesn't set ber_options to the
value ld_lberoptions for extensions (controls & extended operations).
The extension could (in theory) require other options to be properly
encoded/decoded.

>If so is there a way to get
>ld_lberoptions through ldap_get_option or somehow else?  What is the
>rationale behind requiring that the ber_options must be set at
>BerElement's creation time (i. e. why is ber_alloc marked deprecated)?

I suspect the rationale was that the caller knows what options
it wants up front.

>The only way I can think of currently to achieve this is a dirty hack:
>
>int my_get_beroptions(LDAP *ld) {
>    BerElement *ber_tmp = ber_allocate_with_options(ld);
>    int res = ber_tmp->beroptions;
>    ber_free(ber_tmp, 1);
>    return res;u
>}
>
>
>TIA,
>
>aa
>
>-- 
>Andreas Ames | Programmer | Comergo GmbH | 
>Voice:  +49 69 7505 3213 | andreas . ames AT comergo . com