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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:351:    // Note: Might do additional schema queries to the server while    // decoding the result. That means possible interleaving problem    // if search() is extended to not retrieve the complete reply at    // once.       if (!sizeof (entries)) {    seterr (LDAP_LOCAL_ERROR);    THROW(({"LDAP: Internal error.\n",backtrace()}));    return -ldap_errno;    } -  DWRITE(sprintf("result.create: %O\n",entries[-1])); +  DWRITE("result.create: %O\n", entries[-1]);       // The last element of 'entries' is result itself    resultcode = ASN1_RESULTCODE (entries[-1]); -  DWRITE(sprintf("result.create: code=%d\n",resultcode)); +  DWRITE("result.create: code=%d\n", resultcode);    resultstring = ASN1_RESULTSTRING (entries[-1]);    if (resultstring == "")    resultstring = 0;    else if (ldap_version >= 3)    if (mixed err = catch (resultstring = utf8_to_string (resultstring))) -  DWRITE (sprintf ("Failed to decode result string %O: %s", -  resultstring, describe_error (err))); -  DWRITE(sprintf("result.create: str=%O\n",resultstring)); +  DWRITE ("Failed to decode result string %O: %s", +  resultstring, describe_error (err)); +  DWRITE("result.create: str=%O\n", resultstring);   #ifdef V3_REFERRALS    // referral (v3 mode)    if(resultcode == 10) {    referrals = ({});    foreach(ASN1_RESULTREFS (entries[-1]), object ref1)    referrals += ({ ref1->value }); -  DWRITE(sprintf("result.create: refs=%O\n",referrals)); +  DWRITE("result.create: refs=%O\n", referrals);    }   #endif -  DWRITE(sprintf("result.create: elements=%d\n",sizeof (entries))); - #if 0 -  DWRITE(sprintf("result.create: entries=%O\n", entries[..<1])); - #endif +  DWRITE("result.create: elements=%d\n", sizeof(entries));       entry = decode_entries (entries[..<1]);      #if 0    // Context specific proccessing of 'entries'    switch(stuff) { -  case 1: DWRITE("result.create: stuff=1\n"); +  case 1: +  DWRITE("result.create: stuff=1\n");    break; -  default: DWRITE(sprintf("result.create: stuff=%d\n", stuff)); -  +  default: +  DWRITE("result.create: stuff=%d\n", stuff); +  break;    }   #endif       return this; -  +     }       //!    //! Returns the error number in the search result.    //!    //! @seealso    //! @[error_string], @[server_error_string]    int error_number() { return resultcode; }       //!
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:718: Inside #if undefined(PARSE_RFCS)
  #else    if(lauth->scheme == "ldaps") {    THROW(({"LDAP: LDAPS is not available without SSL support.\n",backtrace()}));    }    else    ::create(low_fd);   #endif       DWRITE("client.create: connected!\n");    -  DWRITE(sprintf("client.create: remote = %s\n", low_fd->query_address())); +  DWRITE("client.create: remote = %s\n", low_fd->query_address());    DWRITE_HI("client.OPEN: " + lauth->host + ":" + (string)(lauth->port) + " - OK\n");       reset_options();    } // create   #endif      void reset_options()   //! Resets all connection options, such as the scope and the base DN,   //! to the defaults determined from the LDAP URL when the connection   //! was created.
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:882:    THROW(({error_string()+"\n",backtrace()}));    return 0;    }       bound_dn = md5_password = 0;    last_rv = SIMPLE_RESULT (raw, 1, 0);    if (!last_rv->error_number()) {    bound_dn = dn;    md5_password = Crypto.MD5.hash (pass);    } -  DWRITE_HI(sprintf("client.BIND: %s\n", last_rv->error_string())); +  DWRITE_HI("client.BIND: %s\n", last_rv->error_string());    seterr (last_rv->error_number(), last_rv->error_string());    return !!bound_dn;       } // bind          private int send_unbind_op() {    // UNBIND operation       writemsg(ASN1_APPLICATION_OCTET_STRING(2, ""));
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:960:    return 0;    if(ldap_version == 3) {    dn = string_to_utf8(dn);    }    if(intp(raw = send_op_withdn(10, dn))) {    THROW(({error_string()+"\n",backtrace()}));    return 0;    }       last_rv = SIMPLE_RESULT (raw, 0, 0); -  DWRITE_HI(sprintf("client.DELETE: %s\n", last_rv->error_string())); +  DWRITE_HI("client.DELETE: %s\n", last_rv->error_string());    seterr (last_rv->error_number(), last_rv->error_string());    return !last_rv->error_number();       } // delete       private int|string send_compare_op(string dn, string attr, string value) {    // COMPARE       object msgval;   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1032:    dn = string_to_utf8(dn);    if (function(string:string) encoder = get_attr_encoder (attr))    value = encoder (value);    }    if(intp(raw = send_compare_op(dn, attr, value))) {    THROW(({error_string()+"\n",backtrace()}));    return 0;    }       last_rv = SIMPLE_RESULT (raw, 0, 0); -  DWRITE_HI(sprintf("client.COMPARE: %s\n", last_rv->error_string())); +  DWRITE_HI("client.COMPARE: %s\n", last_rv->error_string());    seterr (last_rv->error_number(), last_rv->error_string());    return last_rv->error_number() == LDAP_COMPARE_TRUE;       } // compare       private int|string send_add_op(string dn, mapping(string:array(string)) attrs) {    // ADD       object msgval;    string atype;
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1108:    foreach (indices(attrs), string attr)    if (function(string:string) encoder = get_attr_encoder (attr))    attrs[attr] = map (attrs[attr], encoder);    }    if(intp(raw = send_add_op(dn, attrs))) {    THROW(({error_string()+"\n",backtrace()}));    return 0;    }       last_rv = SIMPLE_RESULT (raw, 0, 0); -  DWRITE_HI(sprintf("client.ADD: %s\n", last_rv->error_string())); +  DWRITE_HI("client.ADD: %s\n", last_rv->error_string());    seterr (last_rv->error_number(), last_rv->error_string());    return !last_rv->error_number();       } // add      protected mapping(string:array(string)) simple_read (string object_name,    object filter,    array attrs)   // Makes a base object search for object_name. The result is returned   // as a mapping where the attribute types have been lowercased and the
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1394:    //! @[Protocols.LDAP.ldap_encode_string], @[Protocols.LDAP.make_filter]    result|int search (string|object|void filter, array(string)|void attrs,    int|void attrsonly,    void|mapping(string:array(int|string)) controls,    void|int flags) {       int id;    object entry;    array(object) entries = ({});    -  DWRITE_HI(sprintf ("client.SEARCH: %O\n", filter)); +  DWRITE_HI("client.SEARCH: %O\n", filter);    if (chk_ver())    return 0;    if (chk_binded())    return 0;       if (!objectp (filter))    if (mixed err = catch {    if (!filter)    filter = get_default_filter();    else
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1552:       },);    } while (cookie);       PROFILE("result", last_rv = result (entries, 0, flags));    if(objectp(last_rv))    seterr (last_rv->error_number(), last_rv->error_string());    //if (rv->error_number() || !rv->num_entries()) // if error or entries=0    // rv = rv->error_number();    -  DWRITE_HI(sprintf("client.SEARCH: %s (entries: %d)\n", -  last_rv->error_string(), last_rv->num_entries())); +  DWRITE_HI("client.SEARCH: %s (entries: %d)\n", +  last_rv->error_string(), last_rv->num_entries());    return last_rv;       } // search      mapping(string:string|array(string)) read (    string object_name,    void|string filter,    void|array(string) attrs,    void|int attrsonly,    void|mapping(string:array(int|string)) controls,
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1741:    case "sub": scope = SCOPE_SUB; break;    case "one": scope = SCOPE_ONE; break;    case "base": scope = SCOPE_BASE; break;    default: ERROR ("Invalid scope %O.\n", scope);    }    else    if (!(<SCOPE_BASE, SCOPE_ONE, SCOPE_SUB>)[scope])    ERROR ("Invalid scope %O.\n", scope);       ldap_scope = scope; -  DWRITE_HI("client.SET_SCOPE = " + (string)scope + "\n"); +  DWRITE_HI("client.SET_SCOPE = %O\n", scope);    return old_scope;    }      //! Return the currently set scope as a string @expr{"base"@},   //! @expr{"one"@}, or @expr{"sub"@}.   string get_scope()    {return ([SCOPE_BASE: "base", SCOPE_ONE: "one", SCOPE_SUB: "sub"])[ldap_scope];}       //! @param option_type    //! LDAP_OPT_xxx    //! @param value    //! new value for option    int set_option (int opttype, int value) {    -  DWRITE_HI("client.SET_OPTION: " + (string)opttype + " = " + (string)value + "\n"); +  DWRITE_HI("client.SET_OPTION: %O = %O\n", opttype, value);    switch (opttype) {    case 1: // LDAP_OPT_DEREF    //if (intp(value))    ldap_deref = value;    //else    // return -1;    break;    case 2: // LDAP_OPT_SIZELIMIT    //if (intp(value))    ldap_sizelimit = value;
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1789:          return 0;    }       //! @param option_type    //! LDAP_OPT_xxx    int get_option (int opttype) {       -  DWRITE_HI("client.GET_OPTION: " + (string)opttype + "\n"); +  DWRITE_HI("client.GET_OPTION: %O\n", opttype);    switch (opttype) {    case 1: // LDAP_OPT_DEREF    return ldap_deref;    case 2: // LDAP_OPT_SIZELIMIT    return ldap_sizelimit;    case 3: // LDAP_OPT_TIMELIMIT    return ldap_timelimit;    case 4: // LDAP_OPT_REFERRALS    }   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1902:    dn = string_to_utf8(dn);    newrdn = string_to_utf8(newrdn);    if(newsuperior) newsuperior = string_to_utf8(newsuperior);    }    if(intp(raw = send_modifydn_op(dn, newrdn, deleteoldrdn, newsuperior))) {    THROW(({error_string()+"\n",backtrace()}));    return 0;    }       last_rv = SIMPLE_RESULT (raw, 0, 0); -  DWRITE_HI(sprintf("client.MODIFYDN: %s\n", last_rv->error_string())); +  DWRITE_HI("client.MODIFYDN: %s\n", last_rv->error_string());    seterr (last_rv->error_number(), last_rv->error_string());    return !last_rv->error_number();       } //modifydn       //! The Modify Operation allows a client to request that a modification    //! of an entry be performed on its behalf by a server.    //!    //! @param dn    //! The distinguished name of modified entry.
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1978:    op[i] = encoder (op[i]);    attropval[attr] = op;    }    }    if(intp(raw = send_modify_op(dn, attropval))) {    THROW(({error_string()+"\n",backtrace()}));    return 0;    }       last_rv = SIMPLE_RESULT (raw, 0, 0); -  DWRITE_HI(sprintf("client.MODIFY: %s\n", last_rv->error_string())); +  DWRITE_HI("client.MODIFY: %s\n", last_rv->error_string());    seterr (last_rv->error_number(), last_rv->error_string());    return !last_rv->error_number();       } // modify       //! Gets referrals.    //!    //! @returns    //! Returns array of referrals or @expr{0@}.    array|int get_referrals() {