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.26 2001/09/14 08:38:01 hop Exp $ + // $Id: client.pike,v 1.27 2001/09/14 12:37:21 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:110:    private int ldap_deref = 0; // 0: ...    private int ldap_sizelimit = 0;    private int ldap_timelimit = 0;    private mapping lauth = ([]);             //! Contains the result of a LDAP search.    //!    //! @seealso -  //! @[LDAP.client.search, LDAP.client.result.fetch] +  //! @[LDAP.client.search], @[LDAP.client.result.fetch]    //!    class result // ------------------    {       private int resultcode = LDAP_SUCCESS;    private string resultstring;    private int entrycnt = 0;    private int actnum = 0;    private array(mapping(string:array(string))) entry = ({});    array(string) referrals;
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:211:   #endif       return(this_object());       }       //!    //! Returns error number of search result.    //!    //! @seealso -  //! @[LDAP.client.result.error_string] +  //! @[LDAP.client.result.error_string]    int error_number() { return(resultcode); }       //!    //! Returns error description of search result.    //!    //! @seealso -  //! @[LDAP.client.result.error_number] +  //! @[LDAP.client.result.error_number]    string error_string() {    return((stringp(resultstring) && sizeof(resultstring)) ?    resultstring : ldap_errlist[resultcode]);    }       //!    //! Returns the number of entries.    //!    //! @seealso -  //! @[LDAP.client.result.count_entries] +  //! @[LDAP.client.result.count_entries]    int num_entries() { return(entrycnt); }       //!    //! Returns the number of entries from current cursor    //! possition till end of the list.    //!    //! @seealso -  //! @[LDAP.client.result.first, LDAP.client.result.next] +  //! @[LDAP.client.result.first], @[LDAP.client.result.next]    int count_entries() { return(entrycnt - actnum); }       //! @decl mapping(string:array(string)) fetch()    //! @decl mapping(string:array(string)) fetch(int)    //!    //! Returns a mapping with an entry for each attribute.    //! Each entry is an array of values of the attribute.    //!    //! @param idx    //! Optional argument can be used for direct access
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:270:    //! Returns distinguished name (DN) of the current entry    //! in the result list. Notice that this is the same    //! as fetch()->dn[0].    string get_dn() { return(fetch()["dn"][0]); }       //!    //! Initialized the result cursor to the first entry    //! in the result list.    //!    //! @seealso -  //! @[LDAP.client.result.next] +  //! @[LDAP.client.result.next]    void first() { actnum = 0; }       //!    //! Moves the result cursor to the next entry    //! in the result list. Returns number of remained entries    //! in the result list. Returns 0 at the end.    //!    //! @seealso -  //! @[LDAP.client.result.next] +  //! @[LDAP.client.result.next]    int next() {    if (actnum < (num_entries()-1)) {    actnum++;    return(count_entries());    }    return(0);    }       } // end of class 'result' ---------------   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:343:    //! TLS context of connection.    //!    //! @param url    //! LDAP server URL in form    //! @tt{"ldap://hostname/basedn?attrlist?scope?ext"@}    //!    //! @param context    //! TLS context of connection    //!    //! @seealso -  //! @[LDAP.client.bind, LDAP.client.search] +  //! @[LDAP.client.bind], @[LDAP.client.search]    void create(string|void url, object|void context)    {       info = ([]);       if(!url || !sizeof(url))    url = LDAP_DEFAULT_URL;       lauth = parse_url(url);   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:394:    THROW(({"Failed to connect to LDAP server.\n",backtrace()}));    }       if(lauth->scheme == "ldaps") {    context->random = Crypto.randomness.reasonably_random()->read;    ::create(SSL.sslfile(::_fd, context, 1,1));    info->tls_version = ldapfd->version;    } else    ::create(::_fd);    -  connected = 1; +     DWRITE("client.create: connected!\n");       DWRITE(sprintf("client.create: remote = %s\n", query_address()));    DWRITE_HI("client.OPEN: " + lauth->host + ":" + (string)(lauth->port) + " - OK\n");       binded = 0;       if(lauth->scope)    set_scope(lauth->scope);    if(lauth->basedn)
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:497:       return (1);    }       void destroy() {       //send_unbind_op();    destruct(this_object());    }    -  //! @decl int unbind() +     //!    //! Unbinds from the directory and close the connection.    int unbind () {       if (send_unbind_op() < 1) {    THROW(({error_string()+"\n",backtrace()}));    return(-ldap_errno);    }    binded = 0;    DWRITE_HI("client.UNBIND: OK\n");       } // unbind       private int|string send_op_withdn(int op, string dn) {    // DELETE, ...       return (do_op(ASN1_APPLICATION_OCTET_STRING(op, dn)));       }    -  //! @decl int delete(string) +     //!    //! Deletes entry from the LDAP server.    //!    //! @param dn    //! The distinguished name of deleted entry.    int delete (string dn) {       int id;    mixed raw;    object rv;
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:568:    ({ Standards.ASN1.Types.asn1_octet_string(aval[0]),    Standards.ASN1.Types.asn1_octet_string(aval[1])    }))    })    );       return (do_op(msgval));    }       -  // API function (ldap_compare) -  // -  // compare(string dn, array(string) aval) -  // -  // dn: DN of compared object -  // aval: attribute value -  -  //! @decl int compare(string, array) +     //!    //! Compares given attribute value with one in the directory. -  +  //! +  //! @param dn +  //! The distinguished name of compared entry. +  //! +  //! @param aval +  //! The mapping of compared attributes and theirs values.    int compare (string dn, array(string) aval) {       int id;    mixed raw;    object rv;       // if (!aval || sizeof(aval)<2)    // error    if (chk_ver())    return(-ldap_errno);