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.78 2005/03/11 15:33:38 mast Exp $ + // $Id: client.pike,v 1.79 2005/03/11 16:49:57 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:72: Inside #if constant(.ldap_privates)
  #if constant(.ldap_privates)      #include "ldap_globals.h"      #include "ldap_errors.h"      #if constant(SSL.Cipher.CipherAlgorithm)   import SSL.Constants;   #endif    + import Protocols.LDAP; +    // ------------------------      // ASN.1 decode macros      #define ASN1_GET_RESULTAPP(X) ((X)->elements[1]->get_tag())   #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)   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:113:    object last_rv = 0; // last returned value    }      static constant supported_extensions = (<"bindname">);      static function(string:string) get_attr_decoder (string attr,    DO_IF_DEBUG (void|int nowarn))   {    if (mapping(string:mixed) attr_descr = get_attr_type_descr (attr)) {    if (function(string:string) decoder = -  Protocols.LDAP.syntax_decode_fns[attr_descr->syntax_oid]) +  syntax_decode_fns[attr_descr->syntax_oid])    return decoder;   #ifdef DEBUG -  else if (!Protocols.LDAP.get_constant_name (attr_descr->syntax_oid)) +  else if (!get_constant_name (attr_descr->syntax_oid))    werror ("Warning: Unknown syntax %O for attribute %O - "    "binary content assumed.\n", attr_descr->syntax_oid, attr);   #endif    }   #ifdef DEBUG    else if (!nowarn && !has_suffix (attr, ";binary") && !has_value (attr, ";binary;"))    werror ("Warning: Couldn't fetch attribute description for %O - "    "binary content assumed.\n", attr);   #endif    return 0;   }      static function(string:string) get_attr_encoder (string attr)   {    if (mapping(string:mixed) attr_descr = get_attr_type_descr (attr)) {    if (function(string:string) encoder = -  Protocols.LDAP.syntax_encode_fns[attr_descr->syntax_oid]) +  syntax_encode_fns[attr_descr->syntax_oid])    return encoder;   #ifdef DEBUG -  else if (!Protocols.LDAP.get_constant_name (attr_descr->syntax_oid)) +  else if (!get_constant_name (attr_descr->syntax_oid))    werror ("Warning: Unknown syntax %O for attribute %O - "    "binary content assumed.\n", attr_descr->syntax_oid, attr);   #endif    }   #ifdef DEBUG    else if (!has_suffix (attr, ";binary") && !has_value (attr, ";binary;"))    werror ("Warning: Couldn't fetch attribute description for %O - "    "binary content assumed.\n", attr);   #endif    return 0;
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:182:    mapping(string:array) attrs = (["dn": ({ASN1_DECODE_DN (derent)})]); \    foreach (derattribs, object derattr) \    {SET_ATTR;} \    res += ({attrs}); \    } \    } \    } while (0)       if (ldap_version < 3) {    // Use the values raw. -  if (flags & Protocols.LDAP.SEARCH_LOWER_ATTRS) +  if (flags & SEARCH_LOWER_ATTRS)    DECODE_ENTRIES ({    attrs[lower_case (ASN1_GET_ATTR_NAME (derattr))] =    ASN1_GET_ATTR_VALUES (derattr);    });    else    DECODE_ENTRIES ({    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 & Protocols.LDAP.SEARCH_LOWER_ATTRS) +  if (flags & SEARCH_LOWER_ATTRS)    DECODE_ENTRIES ({    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 ({    string attr = ASN1_GET_ATTR_NAME (derattr);
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:473: 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.78 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.79 $"/" ")[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")
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1388:    foreach (controls; string type; array(int|string) data)    common_controls[i++] =    make_control (type, [string] data[1], [int] data[0]);    }    else common_controls = ({});      #if 0    // Microsoft AD stuff that previously was added by default. There    // doesn't appear to be a good reason for it. It's now possible    // for the caller to do it, anyway. /mast -  if (get_supported_controls()[Protocols.LDAP.LDAP_SERVER_DOMAIN_SCOPE_OID]) { +  if (get_supported_controls()[LDAP_SERVER_DOMAIN_SCOPE_OID]) {    // LDAP_SERVER_DOMAIN_SCOPE_OID    // "Tells server not to generate referrals" (NtLdap.h) -  common_controls += ({make_control (Protocols.LDAP.LDAP_SERVER_DOMAIN_SCOPE_OID)}); +  common_controls += ({make_control (LDAP_SERVER_DOMAIN_SCOPE_OID)});    }   #endif      #ifdef ENABLE_PAGED_SEARCH    get_supported_controls();   #endif       object cookie = Standards.ASN1.Types.asn1_octet_string("");    rawarr = ({});    do {    PROFILE("send_search_op", {    array ctrls = common_controls;    IF_ELSE_PAGED_SEARCH ( -  if (supported_controls[Protocols.LDAP.LDAP_PAGED_RESULT_OID_STRING]) { +  if (supported_controls[LDAP_PAGED_RESULT_OID_STRING]) {    // LDAP Control Extension for Simple Paged Results Manipulation    // RFC 2696.    ctrls += ({make_control ( -  Protocols.LDAP.LDAP_PAGED_RESULT_OID_STRING, +  LDAP_PAGED_RESULT_OID_STRING,    Standards.ASN1.Types.asn1_sequence(    ({    // size    Standards.ASN1.Types.asn1_integer(0x7fffffff),    cookie, // cookie    }))->get_der(),    sizeof(cookie->value)?0:0xff)});    },);    object controls;    if (sizeof(ctrls)) {
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1456:    object controls = .ldap_privates.ldap_der_decode(raw)->elements[2];    foreach(controls->elements, object control) {    if (!control->constructed ||    !sizeof(control) ||    control->elements[0]->type_name != "OCTET STRING") {    //werror("Protocol error in control %O\n", control);    // FIXME: Fail?    continue;    }    if (control->elements[0]->value != -  Protocols.LDAP.LDAP_PAGED_RESULT_OID_STRING) { +  LDAP_PAGED_RESULT_OID_STRING) {    //werror("Unknown control %O\n", control->elements[0]->value);    // FIXME: Should look at criticallity flag.    continue;    }    if (sizeof(control) == 1) continue;    int pos = 1;    if (control->elements[1]->type_name == "BOOLEAN") {    if (sizeof(control) == 2) continue;    pos = 2;    }
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:2008:    case 0:    ERROR ("%sExpected %s after term %O at pos %d: %O\n",    errmsg_prefix, what, term_id, sizeof (orig_str) - pos, orig_str);    case 1:    ERROR ("%sUnterminated %s after term %O at pos %d: %O\n",    errmsg_prefix, what, term_id, sizeof (orig_str) - pos, orig_str);    }    if (catch (qstr = utf8_to_string (qstr)))    ERROR ("%sMalformed UTF-8 in %s after term %O at pos %d: %O\n",    term_id, what, sizeof (orig_str) - pos, orig_str); -  return Protocols.LDAP.ldap_decode_string (qstr); +  return ldap_decode_string (qstr);    };    res[term_id] = parse_qdstring ("quoted string");    break;       case "qdstrings": // One or more quoted UTF-8 strings.    if (sscanf (str, "(%*[ ]%s", str)) {    array(string) list = ({});    do {    if (str == "")    ERROR ("%sUnterminated parenthesis after term %O at pos %d: %O\n",
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:2186:   //! It's the schema applicable at the base DN that is queried.   //!   //! @note   //! LDAPv3 is assumed.   {    // Don't bother lowercasing numeric oids. Names never start with a digit.    if (!(<'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'>)[attr[0]])    attr = lower_case (attr);       if (mapping(string:mixed) descr = standard_attrs != 1 && -  Protocols.LDAP._standard_attr_type_descrs[attr]) +  _standard_attr_type_descrs[attr])    return descr;    if (standard_attrs == 2)    return 0;       if (!attr_type_descrs) {    attr_type_descrs = ([]);    if (mapping(string:array(string)) subschema =    query_subschema (ldap_basedn, ({"attributeTypes"})))    if (array(string) attr_types = subschema->attributetypes) {   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:2229:    if (descr->SUP) incomplete += ({descr});    attr_type_descrs[descr->oid] = descr;    foreach (descr->NAME, string name)    attr_type_descrs[lower_case (name)] = descr;    }       void complete (mapping(string:mixed) descr) {    string sup = lower_case (descr->SUP);    mapping(string:mixed) sup_descr =    attr_type_descrs[sup] || -  (standard_attrs != 1 && Protocols.LDAP._standard_attr_type_descrs[sup]); +  (standard_attrs != 1 && _standard_attr_type_descrs[sup]);    if (!sup_descr)    ERROR ("Inconsistency in schema: "    "Got SUP reference to unknown attribute: %O\n", descr);    if (sup_descr->SUP)    complete (sup_descr);    foreach (indices (sup_descr), string term)    if (zero_type (descr[term]))    descr[term] = sup_descr[term];    };    foreach (incomplete, mapping(string:mixed) descr)
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:2312: Inside #if defined(PARSE_RFCS)
   replace (cont[1], " ", "_"), argv[1], cont[0]);    foreach (({"oid", "NAME", "DESC", "OBSOLETE", "SUP", "EQUALITY", "ORDERING",    "SUBSTR", "syntax_oid", "syntax_len", "SINGLE-VALUE", "COLLECTIVE",    "NO-USER-MODIFICATION", "USAGE"}), string term) {    if (mixed val = descr[term]) {    if (arrayp (val))    write (" %O: ({%s}),\n", term,    map (val, lambda (string s) {return sprintf ("%O", s);}) * ", ");    else {    if (string sym = (<"oid", "syntax_oid">)[term] && -  Protocols.LDAP.get_constant_name (val)) +  get_constant_name (val))    write (" %O: %s,\n", term, sym);    else    write (" %O: %O,\n", term, val);    }    }    }    write ("]);\n");    }    }   }      #endif      #else   constant this_program_does_not_exist=1;   #endif