pike.git / lib / modules / Protocols.pmod / LDAP.pmod / client.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1:   #pike __REAL_VERSION__      // LDAP client protocol implementation for Pike.   // - // $Id: client.pike,v 1.80 2005/03/13 13:21:17 mast Exp $ + // $Id: client.pike,v 1.81 2005/03/14 16:07:23 mast Exp $   //   // Honza Petrous, hop@unibase.cz   //   // ----------------------------------------------------------------------   //   // History:   //   // v0.0 1998-05-25 Starting up!   // v1.0 1998-06-21 Core functions (open, bind, unbind, delete, add,   // compare, search), only V2 operations,
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:79:   import SSL.Constants;   #endif      import Protocols.LDAP;      // ------------------------      // ASN.1 decode macros      #define ASN1_GET_RESULTAPP(X) ((X)->elements[1]->get_tag()) + #define ASN1_GET_DN(X) ((X)->elements[0]->value)   #define ASN1_GET_ATTR_ARRAY(X) (sizeof ((X)->elements) > 1 && \    (array) ((X)->elements[1]->elements))   #define ASN1_GET_ATTR_NAME(X) ((X)->elements[0]->value)   #define ASN1_GET_ATTR_VALUES(X) ((X)->elements[1]->elements->value)      #define ASN1_DECODE_RESULTAPP(X) ASN1_GET_RESULTAPP (.ldap_privates.ldap_der_decode(X))   #define ASN1_DECODE_RESULTCODE(X) (int)(.ldap_privates.ldap_der_decode(X)->elements[1]->elements[0]->value->cast_to_int())   #define ASN1_DECODE_RESULTSTRING(X) (.ldap_privates.ldap_der_decode(X)->elements[1]->elements[2]->value)   #define ASN1_DECODE_RESULTREFS(X) (.ldap_privates.ldap_der_decode(X)->elements[1]->elements[3]->elements) - #define ASN1_DECODE_DN(X) utf8_to_string ((X)->elements[0]->value) +    #define ASN1_DECODE_RAWDEBUG(X) (.ldap_privates.ldap_der_decode(X)->debug_string())       //! Contains the client implementation of the LDAP protocol.    //! All of the version 2 protocol features are implemented    //! but only the base parts of the version 3.       inherit .protocol;       private {    int binded = 0; // flag for v2 operations
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:170:    private string resultstring;    private int actnum = 0;    private array(mapping(string:array(string))) entry = ({});    private int flags;    array(string) referrals;       static array decode_entries (array(string) rawres)    {    array(mapping(string:array(string))) res = ({});    - #define DECODE_ENTRIES(SET_ATTR) do { \ + #define DECODE_ENTRIES(SET_DN, SET_ATTR) do { \    foreach (rawres, string rawent) { \    object derent = .ldap_privates.ldap_der_decode (rawent)->elements[1]; \    if (array(object) derattribs = ASN1_GET_ATTR_ARRAY (derent)) { \ -  mapping(string:array) attrs = (["dn": ({ASN1_DECODE_DN (derent)})]); \ +  mapping(string:array) attrs = (["dn": ({SET_DN})]); \    foreach (derattribs, object derattr) \    {SET_ATTR;} \    res += ({attrs}); \    } \    } \    } while (0)       if (ldap_version < 3) {    // Use the values raw.    if (flags & SEARCH_LOWER_ATTRS) -  DECODE_ENTRIES ({ +  DECODE_ENTRIES (ASN1_GET_DN (derent), {    attrs[lower_case (ASN1_GET_ATTR_NAME (derattr))] =    ASN1_GET_ATTR_VALUES (derattr);    });    else -  DECODE_ENTRIES ({ +  DECODE_ENTRIES (ASN1_GET_DN (derent), {    attrs[ASN1_GET_ATTR_NAME (derattr)] =    ASN1_GET_ATTR_VALUES (derattr);    });    }       else {    // LDAPv3: Decode values as appropriate according to the    // schema. Note that attributes with the ";binary" option    // won't be matched by get_attr_type_descr and are therefore    // left untouched.    if (flags & SEARCH_LOWER_ATTRS) -  DECODE_ENTRIES ({ +  DECODE_ENTRIES (utf8_to_string (ASN1_GET_DN (derent)), {    string attr = lower_case (ASN1_GET_ATTR_NAME (derattr));    if (function(string:string) decoder = get_attr_decoder (attr))    attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder);    else    attrs[attr] = ASN1_GET_ATTR_VALUES (derattr);    });    else -  DECODE_ENTRIES ({ +  DECODE_ENTRIES (utf8_to_string (ASN1_GET_DN (derent)), {    string attr = ASN1_GET_ATTR_NAME (derattr);    if (function(string:string) decoder = get_attr_decoder (attr))    attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder);    else    attrs[attr] = ASN1_GET_ATTR_VALUES (derattr);    });    }      #undef DECODE_ENTRIES   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:475: Inside #if undefined(PARSE_RFCS)
   //! 2255.    //!    //! @param context    //! TLS context of connection    //!    //! @seealso    //! @[LDAP.client.bind], @[LDAP.client.search]    void create(string|void url, object|void context)    {    -  info = ([ "code_revision" : ("$Revision: 1.80 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.81 $"/" ")[1] ]);       if(!url || !sizeof(url))    url = LDAP_DEFAULT_URL;       lauth = parse_url(url);       if(!stringp(lauth->scheme) ||    ((lauth->scheme != "ldap")   #if constant(SSL.Cipher.CipherAlgorithm)    && (lauth->scheme != "ldaps")