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.58 2004/06/18 13:05:50 grubba Exp $ + // $Id: client.pike,v 1.59 2004/06/18 15:16:32 grubba 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:363:    //! @expr{"ldap://hostname/basedn?attrlist?scope?ext"@}    //!    //! @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.58 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.59 $"/" ")[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:930:    ({ Standards.ASN1.Types.asn1_octet_string(basedn),    ASN1_ENUMERATED(scope),    ASN1_ENUMERATED(deref),    Standards.ASN1.Types.asn1_integer(sizelimit),    Standards.ASN1.Types.asn1_integer(timelimit),    ASN1_BOOLEAN(attrsonly ? -1 : 0),    @ohlp    })) ;    }    + IF_ELSE_PAGED_SEARCH(static multiset(string) supported_controls;,)       //! Search LDAP directory.    //!    //! @param filter    //! Search filter used when searching directory objects.    //!    //! @param attrs    //! The array of attribute names which will be returned by server.    //! for every entry.    //!
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:976:       DWRITE_HI("client.SEARCH: " + (string)filter + "\n");    if (chk_ver())    return 0;    if (chk_binded())    return 0;    if(ldap_version == 3) {    filter = string_to_utf8(filter);    }    -  object|int search_request = +  object|int search_request; +  +  IF_ELSE_PAGED_SEARCH({ +  if (!supported_controls) { +  // We need to find out if controls are supported. +  PROFILE("supported_controls", { +  supported_controls = (<>); +  search_request = +  make_search_op("", 0, 0, 0, 0, 0, +  "(objectClass=*)", ({"supportedControl"})); +  //werror("search_request: %O\n", search_request); +  if(intp(raw = do_op(search_request))) { +  THROW(({error_string()+"\n",backtrace()})); +  return 0; +  } +  do { +  object res = .ldap_privates.ldap_der_decode(raw); +  if (res->elements[1]->get_tag() == 5) break; +  //werror("res: %O\n", res); +  foreach(res->elements[1]->elements[1]->elements, object attr) { +  if (attr->elements[0]->value == "supportedControl") { +  supported_controls |= (< +  @(attr->elements[1]->elements->value) +  >); +  //werror("supported_controls: %O\n", supported_controls); +  } +  } +  if (intp(raw = readmsg(id))) { +  THROW(({error_string()+"\n",backtrace()})); +  return 0; +  } +  } while (0); +  }); +  } +  },); +  +  search_request =    make_search_op(ldap_basedn, ldap_scope, ldap_deref,    ldap_sizelimit, ldap_timelimit, attrsonly, filter,    attrs||lauth->attributes);       if(intp(search_request)) {    THROW(({error_string()+"\n",backtrace()}));    return 0;    }       object cookie = Standards.ASN1.Types.asn1_octet_string("");    rawarr = ({});    do {    PROFILE("send_search_op", {    IF_ELSE_PAGED_SEARCH( -  object controls = -  .ldap_privates.asn1_sequence(0, ({ +  array ctrls = ({}); +  if (supported_controls["1.2.840.113556.1.4.1339"]) {    // LDAP_SERVER_DOMAIN_SCOPE_OID    // "Tells server not to generate referrals" (NtLdap.h) -  +  ctrls += ({    Standards.ASN1.Types.asn1_sequence(({    // controlType    Standards.ASN1.Types.asn1_octet_string("1.2.840.113556.1.4.1339"),    ASN1_BOOLEAN(0), // criticality (FALSE)    // controlValue    Standards.ASN1.Types.asn1_octet_string(""),    })), -  +  }); +  } +  if (supported_controls["1.2.840.113556.1.4.319"]) {    // LDAP Control Extension for Simple Paged Results Manipulation    // RFC 2696. -  +  ctrls += ({    Standards.ASN1.Types.asn1_sequence(({    // controlType    Standards.ASN1.Types.asn1_octet_string("1.2.840.113556.1.4.319"),    ASN1_BOOLEAN(sizeof(cookie->value)?0:0xff), // criticality    // controlValue    Standards.ASN1.Types.asn1_octet_string(    Standards.ASN1.Types.asn1_sequence(({    // size    Standards.ASN1.Types.asn1_integer(0x7fffffff),    cookie, // cookie    }))->get_der()),    })), -  })),); +  }); +  } +  object controls; +  if (sizeof(ctrls)) { +  controls = .ldap_privates.asn1_sequence(0, ctrls); +  } +  ,);       if(intp(raw = do_op(search_request,    IF_ELSE_PAGED_SEARCH(controls, 0)))) {    THROW(({error_string()+"\n",backtrace()}));    return 0;    }    });       PROFILE("rawarr++", {    rawarr += ({raw});