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.24 2001/06/21 11:33:06 hop Exp $ + // $Id: client.pike,v 1.25 2001/08/15 18:10:54 hop 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:76: Inside #if defined(LDAP_PROTOCOL_PROFILE)
     #ifdef LDAP_PROTOCOL_PROFILE   int _prof_gtim;   #endif      // ------------------------      // ASN.1 decode macros   #define ASN1_DECODE_RESULTAPP(X) (.ldap_privates.ldap_der_decode(X)->elements[1]->get_tag())   #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[1]->value) + #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_ENTRIES(X) _New_decode(X)   #define ASN1_DECODE_DN(X) (string)((X)->elements[0]->value)   #define ASN1_DECODE_RAWDEBUG(X) (.ldap_privates.ldap_der_decode(X)->debug_string())   #define ASN1_GET_ATTR_ARRAY(X) (array)((X)->elements[1]->elements)   #define ASN1_GET_ATTR_NAME(X) ((X)->elements[0]->value)       inherit .protocol;       private int binded = 0; // flag for v2 operations    private string ldap_basedn = ""; // baseDN
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:99:    private int ldap_sizelimit = 0;    private int ldap_timelimit = 0;    private mapping lauth = ([]);             class result // ------------------    {       private int resultcode = LDAP_SUCCESS; -  //private string resultstring = LDAP_SUCCESS_STR; +  private string resultstring;    private int entrycnt = 0;    private int actnum = 0;    private array(mapping(string:array(string))) entry = ({}); -  +  array(string) referrals;       int error_number() { return(resultcode); }    -  string error_string() { return(ldap_errlist[resultcode]); } +  string error_string() { +  return((stringp(resultstring) && sizeof(resultstring)) ? +  resultstring : ldap_errlist[resultcode]); +  }       int num_entries() { return(entrycnt); }       int count_entries() { return(entrycnt - actnum); }    -  +     private array _get_attr_values(int ver, object x) {       array res = ({});       if(!sizeof(x->elements))    return(res);    foreach(x->elements[1]->elements, object val1)    res += ({ val1->value });    if(ver == 3) {    // deUTF8
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:164:    if (lastel < 0) {    ::seterr (LDAP_LOCAL_ERROR);    THROW(({"LDAP: Internal error.\n",backtrace()}));    return(-::ldap_errno);    }    DWRITE(sprintf("result.create: rawres=%O\n",rawres[lastel]));       // The last element of 'rawres' is result itself    resultcode = ASN1_DECODE_RESULTCODE(rawres[lastel]);    DWRITE(sprintf("result.create: code=%d\n",resultcode)); -  #if 0 +     resultstring = ASN1_DECODE_RESULTSTRING(rawres[lastel]); -  DWRITE(sprintf("result.create: resstr=%s\n",resultstring)); -  #endif +  DWRITE(sprintf("result.create: str=%s\n",resultstring)); + #ifdef V3_REFERRALS    // referral (v3 mode) -  // ... +  if(resultcode == 10) { +  referrals = ({}); +  foreach(ASN1_DECODE_RESULTREFS(rawres[lastel]), object ref1) +  referrals += ({ ref1->value }); +  DWRITE(sprintf("result.create: refs=%O\n",referrals)); +  } + #endif    DWRITE(sprintf("result.create: elements=%d\n",lastel+1));    if (lastel) { // Have we any entry?    entry = ASN1_DECODE_ENTRIES(rawres[..lastel-1]);    entrycnt = sizeof(entry); //num_entries();    }      #if 0    // Context specific proccessing of 'rawres'    switch(stuff) {    case 1: DWRITE("result.create: stuff=1\n");
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:779: Inside #if defined(LDAP_PROTOCOL_PROFILEx)
   while (ASN1_DECODE_RESULTAPP(raw) != 5) {   #ifdef LDAP_PROTOCOL_PROFILEx    DWRITE_PROF("readmsg: %O\n", gauge { raw = readmsg(id); });   #else    raw = readmsg(id);   #endif    if (intp(raw)) {    THROW(({error_string()+"\n",backtrace()}));    return(-ldap_errno);    } - #ifdef V3_REFERRALS -  nv = ASN1_DECODE_RESULTAPP(raw); -  if(nv == 4 || nv == 5) +     rawarr += ({raw}); -  else { -  DWRITE(sprintf("client.search: APP[%d]\n",ASN1_DECODE_RESULTAPP(raw))); -  // in version 3 - referrals -  } - #else -  rawarr += ({raw}); // search op is about 20-25% faster without referral checks! - #endif +     } // while   #ifdef LDAP_PROTOCOL_PROFILE    };    DWRITE_PROF("rawarr++: %O\n", _prof_gtim);   #endif      #ifdef LDAP_PROTOCOL_PROFILE    _prof_gtim = gauge{ rv = result(rawarr); };    DWRITE_PROF("result: %O\n", _prof_gtim);   #else