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.98 2006/05/10 12:17:37 mast Exp $ + // $Id: client.pike,v 1.99 2006/05/11 12:36:25 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:553: Inside #if undefined(PARSE_RFCS)
   //! @[Protocol.LDAP.parse_ldap_url].    //!    //! @param context    //! TLS context of connection    //!    //! @seealso    //! @[LDAP.client.bind], @[LDAP.client.search]    void create(string|mapping(string:mixed)|void url, object|void context)    {    -  info = ([ "code_revision" : ("$Revision: 1.98 $"/" ")[1] ]); +  info = ([ "code_revision" : ("$Revision: 1.99 $"/" ")[1] ]);       if(!url || !sizeof(url))    url = LDAP_DEFAULT_URL;       if (mappingp (url))    lauth = url;    else    lauth = parse_ldap_url(url);       if(!stringp(lauth->scheme) ||
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1962:    }    return res;    }    }       return 0;   }      static mapping(string:mixed) parse_schema_terms (    string str, -  mapping(string:string|multiset(string)) known_terms, +  mapping(string:string|multiset|mapping) known_terms,    string errmsg_prefix)   // Parses a string containing a parenthesized list of terms as used in   // several schema related attributes. The known_terms mapping   // specifies the syntax of the known terms. If there's an entry "" in   // it it's used for all other encountered terms.   {    string orig_str = str, oid;       // RFC 2252 mandates a dotted decimal oid here, but some servers    // (e.g. iPlanet) might use symbolic strings so we have to do a lax
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:2121:    errmsg_prefix, term_id, sizeof (orig_str) - pos, orig_str);    list += ({parse_qdescr ("quoted descr in list")});    } while (!sscanf (str, ")%*[ ]%s", str));    res[term_id] = list;    }    else    res[term_id] = ({parse_qdescr ("quoted descr")});    break;       default: -  if (multisetp (term_syntax)) { // One of a set. +  if (multisetp (term_syntax) || mappingp (term_syntax)) { +  // One of a set.    sscanf (str, "%[-;a-zA-Z0-9.]%*[ ]%s", string choice, str);    if (!sizeof (choice))    ERROR ("%sExpected keyword after term %O at pos %d: %O\n",    errmsg_prefix, term_id, sizeof (orig_str) - pos, orig_str); -  if (!term_syntax[choice]) +  if (term_syntax[1]) choice = lower_case (choice); +  string|int lookup = term_syntax[choice]; +  if (!lookup)    ERROR ("%sUnknown keyword after term %O at pos %d: %O\n",    errmsg_prefix, term_id, sizeof (orig_str) - pos, orig_str); -  res[term_id] = choice; +  res[term_id] = stringp (lookup) ? lookup : choice;    break;    }       ERROR ("Unknown syntax %O in known_perms.\n", term_syntax);    }    } while (!sscanf (str, ")%s", str));       if (str != "")    ERROR ("%sUnexpected data after ending ')' at pos %d: %O\n",    errmsg_prefix, sizeof (orig_str) - sizeof (str) - 1, orig_str);       return res;   }    -  + static constant attr_type_term_syntax = ([ +  "NAME": "qdescrs", +  "DESC": "qdstring", +  "OBSOLETE": "flag", +  "SUP": "oid", +  "EQUALITY": "oid", +  "ORDERING": "oid", +  "SUBSTR": "oid", +  "SYNTAX": "oidlen", +  "SINGLE-VALUE": "flag", +  "COLLECTIVE": "flag", +  "NO-USER-MODIFICATION": "flag", +  "USAGE": ([ +  1: 1, // This flags case insensitive matching. +  // The alternatives here are not case insensitive according to RFC +  // 2252, but of course the iPlanet LDAP server manages to return +  // "dsaOperation" instead of "dSAOperation". :P +  "userapplications": "userApplications", +  "directoryoperation": "directoryOperation", +  "distributedoperation": "distributedOperation", +  "dsaoperation": "dSAOperation" +  ]), +  "": "qdstrings" + ]); +    static mapping(string:mapping(string:mixed)) attr_type_descrs;      mapping(string:mixed) get_attr_type_descr (string attr, void|int standard_attrs)   //! Returns the attribute type description for the given attribute,   //! which includes the name, object identifier, syntax, etc (see   //! section 4.2 in RFC 2252 for details).   //!   //! This might do a query to the server, but results are cached.   //!   //! @param attr
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:2268:    query_subschema (ldap_basedn, ({"attributeTypes"})))    if (array(string) attr_types = subschema->attributetypes) {       // Note partial code dup with    // Protocols.LDAP._standard_attr_type_descrs init.    array(mapping(string:mixed)) incomplete = ({});       foreach (attr_types, string attr_type) {    mapping(string:mixed) descr = parse_schema_terms (    utf8_to_string (attr_type), -  (["NAME": "qdescrs", -  "DESC": "qdstring", -  "OBSOLETE": "flag", -  "SUP": "oid", -  "EQUALITY": "oid", -  "ORDERING": "oid", -  "SUBSTR": "oid", -  "SYNTAX": "oidlen", -  "SINGLE-VALUE": "flag", -  "COLLECTIVE": "flag", -  "NO-USER-MODIFICATION": "flag", -  "USAGE": (<"userApplications", "directoryOperation", -  "distributedOperation", "dSAOperation">), -  "": "qdstrings"]), +  attr_type_term_syntax,    "Error in attributeTypes when querying schema: ");    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 =
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/client.pike:2347: Inside #if defined(PARSE_RFCS)
   for (int n = 0; n < sizeof (cont); n++) {    if (sscanf (cont[n], "%*[ \t](%*s") == 2 &&    (n == 0 || String.trim_whites (cont[n-1]) == "")) {    string expr = String.trim_whites (cont[n]), s;    for (n++; n < sizeof (cont) && (s = String.trim_whites (cont[n])) != ""; n++)    expr += " " + s;       mapping descr;    if (mixed err =    catch (descr = parse_schema_terms ( -  expr, -  (["NAME": "qdescrs", -  "DESC": "qdstring", -  "OBSOLETE": "flag", -  "SUP": "oid", -  "EQUALITY": "oid", -  "ORDERING": "oid", -  "SUBSTR": "oid", -  "SYNTAX": "oidlen", -  "SINGLE-VALUE": "flag", -  "COLLECTIVE": "flag", -  "NO-USER-MODIFICATION": "flag", -  "USAGE": (<"userApplications", "directoryOperation", -  "distributedOperation", "dSAOperation">), -  "": "qdstrings"]), -  ""))) +  expr, attr_type_term_syntax, "")))    werror (describe_error (err));       write ("constant ATD_%s = ([ // %s, %s\n",    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,