Aurynn Shaw wrote:
>
> I'm trying to parse a foo.schema file, which appears to be in the
>
> attributetype ( 1.3.6.1.4.1.11940.1
> NAME 'startDate'
> DESC 'Flash Code user subscription start date'
> EQUALITY caseIgnoreMatch
> SUBSTR caseIgnoreSubstringsMatch
> SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
>
> style format, instead of LDIF.
>
> ldap.schema seems to indicate that it can parse LDAP schemas. Is that
> in this format, or does it require a connection to the LDAP server?
Mind the line-wrapping:
Python 2.5.1 (r251:54863, Apr 19 2007, 12:23:24)
[GCC 4.1.2 20061115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a="""attributetype ( 1.3.6.1.4.1.11940.1
... NAME 'startDate'
... DESC 'Flash Code user subscription start date'
... EQUALITY caseIgnoreMatch
... SUBSTR caseIgnoreSubstringsMatch
... SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
... """
>>> import ldap.schema
>>> at=ldap.schema.AttributeType(a[len('attributetype
'):].replace('\n',' '))
>>> at
<ldap.schema.models.AttributeType instance at 0xb779ee6c>
>>> dir(at)
['__doc__', '__init__', '__module__', '__str__', '_set_attrs',
'collective', 'desc', 'equality', 'get_id', 'key_attr', 'key_list',
'names', 'no_user_mod', 'obsolete', 'oid', 'ordering',
'schema_attribute', 'set_id', 'single_value', 'substr', 'sup', 'syntax',
'syntax_len', 'token_defaults', 'usage']
Same for other schema elements.
Ciao, Michael.
|