ldap.schema: str2objectclass() fails

Hans Aschauer Hans.Aschauer at Physik.uni-muenchen.de
Mon Jul 29 14:10:36 CEST 2002


On Samstag, 27. Juli 2002 22:38, Michael Ströder wrote:
> HI!
>
> ldap.schema.str2objectclass() fails when parsing the following
> string (from Netscape DS 4.16SP1 sub schema sub entry):
>
> "( 2.5.6.1 NAME 'alias' DESC 'Standard ObjectClass' SUP 'top' MUST
> ( objectclass $ aliasedObjectName )  MAY ( aci ) )"
>
> This schema string does not look unusual to me but...

But it does to me. The "SUP 'top'" should be "SUP top" (as far as I 
understand RFC 2252, Chapter 4: the argument of sup is oids, which does 
not include the quotes...). Just tried it, and it worked.

One way to solve this problem (if netscape DS always returns such 
'wrong' sub schema sub entries) would be to expose the flags argument 
of the C function to the python API, which allows to be more liberal in 
parsing the strings. The flags are defined in ldap_schema.h:

#define LDAP_SCHEMA_ALLOW_NONE		0x00 /* Strict parsing               */
#define LDAP_SCHEMA_ALLOW_NO_OID	0x01 /* Allow missing oid            */
#define LDAP_SCHEMA_ALLOW_QUOTED	0x02 /* Allow bogus extra quotes     */
#define LDAP_SCHEMA_ALLOW_DESCR		0x04 /* Allow descr instead of OID   */
#define LDAP_SCHEMA_ALLOW_DESCR_PREFIX	0x08 /* Allow descr as OID prefix    
*/
#define LDAP_SCHEMA_ALLOW_OID_MACRO	0x10 /* Allow OID macros in slapd    
*/
#define LDAP_SCHEMA_ALLOW_ALL		0x1f /* Be very liberal in parsing   */

At present, the flags are set to 0x00...



[incomplete and 'bad' python error]

> Well, I'd like to see some better error reporting with the help of
> exceptions. Anyway, there is a debug output text "Error: 6: .."
> produced. Don't know whether by the OpenLDAP libs or some code in
> Modules/schema.c.

Sorry that I still have not implemented correct error handling...
The return codes are (again from ldap_schema.h):

/* Codes for parsing errors */

#define LDAP_SCHERR_OUTOFMEM		1
#define LDAP_SCHERR_UNEXPTOKEN		2
#define LDAP_SCHERR_NOLEFTPAREN		3
#define LDAP_SCHERR_NORIGHTPAREN	4
#define LDAP_SCHERR_NODIGIT		5
#define LDAP_SCHERR_BADNAME		6
#define LDAP_SCHERR_BADDESC		7
#define LDAP_SCHERR_BADSUP		8
#define LDAP_SCHERR_DUPOPT		9
#define LDAP_SCHERR_EMPTY		10


> Hans, before I ask on the OpenLDAP list what this error means can
> you please review your code and test with the string above? Make
> sure to bring your CVS working tree in sync!

Ok, I can try to fix things along the lines of David's patch (but 
including the error code). It will however take me at least one week. 

Hans

-- 
Hans.Aschauer at Physik.uni-muenchen.de






More information about the python-ldap mailing list