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.100 2006/05/29 12:58:55 mast Exp $ + // $Id: client.pike,v 1.101 2006/06/22 15:39: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:174:       static array decode_entries (array(string) rawres)    {    array(mapping(string:string|array(string))) res = ({});      #define DECODE_ENTRIES(SET_DN, SET_ATTR) do { \    if (flags & SEARCH_MULTIVAL_ARRAYS_ONLY) { \    foreach (rawres, string rawent) { \    object derent = .ldap_privates.ldap_der_decode (rawent)->elements[1]; \    if (array(object) derattribs = ASN1_GET_ATTR_ARRAY (derent)) { \ -  string dn = (SET_DN); \ +  string dn; \ +  {SET_DN;} \    mapping(string:string|array) attrs = (["dn": dn]); \    foreach (derattribs, object derattr) { \    string attr; \    {SET_ATTR;} \    sscanf (attr, "%[^;]", string bare_attr); \    if (mapping(string:mixed) attr_descr = \    get_attr_type_descr (bare_attr)) { \    if (attr_descr["SINGLE-VALUE"]) { \    if (sizeof (attrs[attr])) { \    DO_IF_DEBUG ( \
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:210:    } \    res += ({attrs}); \    } \    } \    } \    \    else { \    foreach (rawres, string rawent) { \    object derent = .ldap_privates.ldap_der_decode (rawent)->elements[1]; \    if (array(object) derattribs = ASN1_GET_ATTR_ARRAY (derent)) { \ -  string dn = (SET_DN); \ +  string dn; \ +  {SET_DN;} \    mapping(string:array) attrs = (["dn": ({dn})]); \    foreach (derattribs, object derattr) { \    string attr; \    {SET_ATTR;} \    } \    res += ({attrs}); \    } \    } \    } \    } while (0)
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:241:    "Used attribute type %O, server reports %O\n", \    VALUE, ATTR, DECODER_FN, err[0], descr1, descr2); \    }; \    throw (err); \    } \    } while (0)       if (ldap_version < 3) {    // Use the values raw.    if (flags & SEARCH_LOWER_ATTRS) -  DECODE_ENTRIES (ASN1_GET_DN (derent), { +  DECODE_ENTRIES (dn = ASN1_GET_DN (derent), {    attrs[attr = lower_case (ASN1_GET_ATTR_NAME (derattr))] =    ASN1_GET_ATTR_VALUES (derattr);    });    else -  DECODE_ENTRIES (ASN1_GET_DN (derent), { +  DECODE_ENTRIES (dn = ASN1_GET_DN (derent), {    attrs[attr = 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 (utf8_to_string (ASN1_GET_DN (derent)), { +  DECODE_ENTRIES ({ +  string enc_dn = ASN1_GET_DN (derent); +  if (mixed err = catch (dn = utf8_to_string (enc_dn))) { +  catch { +  err[0] += sprintf ("Value to decode was: %O\n", enc_dn); +  }; +  throw (err); +  } +  }, {    attr = lower_case (ASN1_GET_ATTR_NAME (derattr));    if (function(string:string) decoder =    // Microsoft AD has several attributes in its root DSE    // that they have not bothered to include in their    // schema. So if this is the root being fetched then    // send the nowarn flag to get_attr_encoder to avoid    // complaints about that.    get_attr_decoder (attr, DO_IF_DEBUG (dn == "")))    IMPROVE_DECODE_ERRS (    attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder),    attr, ASN1_GET_ATTR_VALUES (derattr), decoder);    else    attrs[attr] = ASN1_GET_ATTR_VALUES (derattr);    });    else -  DECODE_ENTRIES (utf8_to_string (ASN1_GET_DN (derent)), { +  DECODE_ENTRIES ({ +  string enc_dn = ASN1_GET_DN (derent); +  if (mixed err = catch (dn = utf8_to_string (enc_dn))) { +  catch { +  err[0] += sprintf ("Value to decode was: %O\n", enc_dn); +  }; +  throw (err); +  } +  }, {    attr = ASN1_GET_ATTR_NAME (derattr);    if (function(string:string) decoder =    get_attr_decoder (attr, DO_IF_DEBUG (dn == "")))    IMPROVE_DECODE_ERRS (    attrs[attr] = map (ASN1_GET_ATTR_VALUES (derattr), decoder),    attr, ASN1_GET_ATTR_VALUES (derattr), decoder);    else    attrs[attr] = ASN1_GET_ATTR_VALUES (derattr);    });    }
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:573: Inside #if undefined(PARSE_RFCS)
   //! @[Protocol.LDAP.parse_ldap_url].    //!    //! @param context    //! TLS context of connection    //!    //! @seealso    //! @[LDAP.client.bind], @[LDAP.client.search]    void create(string|mapping(string:mixed)|void url, object|void context)    {    -  info = ([ "code_revision" : ("$Revision: 1.100 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.101 $"/" ")[1] ]);       if(!url || !sizeof(url))    url = LDAP_DEFAULT_URL;       if (mappingp (url))    lauth = url;    else    lauth = parse_ldap_url(url);       if(!stringp(lauth->scheme) ||