Skip to content

Commit bdf7820

Browse files
authored
Merge PR python-ldap#247 – Add support for X-ORIGIN in ldap.schema's ObjectClass
python-ldap#247
2 parents 7ce471e + 9c48d3e commit bdf7820

File tree

2 files changed

+251
-60
lines changed

2 files changed

+251
-60
lines changed

Lib/ldap/schema/models.py

Lines changed: 77 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,32 @@ class ObjectClass(SchemaElement):
106106
oid
107107
OID assigned to the object class
108108
names
109-
This list of strings contains all NAMEs of the object class
109+
All NAMEs of the object class (tuple of strings)
110110
desc
111-
This string contains description text (DESC) of the object class
111+
Description text (DESC) of the object class (string, or None if missing)
112112
obsolete
113113
Integer flag (0 or 1) indicating whether the object class is marked
114114
as OBSOLETE in the schema
115115
must
116-
This list of strings contains NAMEs or OIDs of all attributes
117-
an entry of the object class must have
116+
NAMEs or OIDs of all attributes an entry of the object class must have
117+
(tuple of strings)
118118
may
119-
This list of strings contains NAMEs or OIDs of additional attributes
120-
an entry of the object class may have
119+
NAMEs or OIDs of additional attributes an entry of the object class may
120+
have (tuple of strings)
121121
kind
122122
Kind of an object class:
123123
0 = STRUCTURAL,
124124
1 = ABSTRACT,
125125
2 = AUXILIARY
126126
sup
127-
This list of strings contains NAMEs or OIDs of object classes
128-
this object class is derived from
127+
NAMEs or OIDs of object classes this object class is derived from
128+
(tuple of strings)
129+
x_origin
130+
Value of the X-ORIGIN extension flag (tuple of strings)
131+
132+
Although it's not official, X-ORIGIN is used in several LDAP server
133+
implementations to indicate the source of the associated schema
134+
element
129135
"""
130136
schema_attribute = u'objectClasses'
131137
token_defaults = {
@@ -137,7 +143,8 @@ class ObjectClass(SchemaElement):
137143
'AUXILIARY':None,
138144
'ABSTRACT':None,
139145
'MUST':(()),
140-
'MAY':()
146+
'MAY':(),
147+
'X-ORIGIN':()
141148
}
142149

143150
def _set_attrs(self,l,d):
@@ -146,6 +153,7 @@ def _set_attrs(self,l,d):
146153
self.desc = d['DESC'][0]
147154
self.must = d['MUST']
148155
self.may = d['MAY']
156+
self.x_origin = d['X-ORIGIN']
149157
# Default is STRUCTURAL, see RFC2552 or draft-ietf-ldapbis-syntaxes
150158
self.kind = 0
151159
if d['ABSTRACT']!=None:
@@ -168,6 +176,7 @@ def __str__(self):
168176
result.append({0:' STRUCTURAL',1:' ABSTRACT',2:' AUXILIARY'}[self.kind])
169177
result.append(self.key_list('MUST',self.must,sep=' $ '))
170178
result.append(self.key_list('MAY',self.may,sep=' $ '))
179+
result.append(self.key_list('X-ORIGIN',self.x_origin,quoted=1))
171180
return '( %s )' % ''.join(result)
172181

173182

@@ -190,40 +199,46 @@ class AttributeType(SchemaElement):
190199
Class attributes:
191200
192201
oid
193-
OID assigned to the attribute type
202+
OID assigned to the attribute type (string)
194203
names
195-
This list of strings contains all NAMEs of the attribute type
204+
All NAMEs of the attribute type (tuple of strings)
196205
desc
197-
This string contains description text (DESC) of the attribute type
206+
Description text (DESC) of the attribute type (string, or None if missing)
198207
obsolete
199208
Integer flag (0 or 1) indicating whether the attribute type is marked
200209
as OBSOLETE in the schema
201210
single_value
202211
Integer flag (0 or 1) indicating whether the attribute must
203212
have only one value
204213
syntax
205-
String contains OID of the LDAP syntax assigned to the attribute type
214+
OID of the LDAP syntax assigned to the attribute type
206215
no_user_mod
207216
Integer flag (0 or 1) indicating whether the attribute is modifiable
208217
by a client application
209218
equality
210-
String contains NAME or OID of the matching rule used for
211-
checking whether attribute values are equal
219+
NAME or OID of the matching rule used for checking whether attribute values
220+
are equal (string, or None if missing)
212221
substr
213-
String contains NAME or OID of the matching rule used for
214-
checking whether an attribute value contains another value
222+
NAME or OID of the matching rule used for checking whether an attribute
223+
value contains another value (string, or None if missing)
215224
ordering
216-
String contains NAME or OID of the matching rule used for
217-
checking whether attribute values are lesser-equal than
225+
NAME or OID of the matching rule used for checking whether attribute values
226+
are lesser-equal than (string, or None if missing)
218227
usage
219228
USAGE of an attribute type:
220229
0 = userApplications
221230
1 = directoryOperation,
222231
2 = distributedOperation,
223232
3 = dSAOperation
224233
sup
225-
This list of strings contains NAMEs or OIDs of attribute types
226-
this attribute type is derived from
234+
NAMEs or OIDs of attribute types this attribute type is derived from
235+
(tuple of strings)
236+
x_origin
237+
Value of the X-ORIGIN extension flag (tuple of strings).
238+
239+
Although it's not official, X-ORIGIN is used in several LDAP server
240+
implementations to indicate the source of the associated schema
241+
element
227242
"""
228243
schema_attribute = u'attributeTypes'
229244
token_defaults = {
@@ -239,7 +254,7 @@ class AttributeType(SchemaElement):
239254
'COLLECTIVE':None,
240255
'NO-USER-MODIFICATION':None,
241256
'USAGE':('userApplications',),
242-
'X-ORIGIN':(None,),
257+
'X-ORIGIN':(),
243258
'X-ORDERED':(None,),
244259
}
245260

@@ -251,7 +266,7 @@ def _set_attrs(self,l,d):
251266
self.equality = d['EQUALITY'][0]
252267
self.ordering = d['ORDERING'][0]
253268
self.substr = d['SUBSTR'][0]
254-
self.x_origin = d['X-ORIGIN'][0]
269+
self.x_origin = d['X-ORIGIN']
255270
self.x_ordered = d['X-ORDERED'][0]
256271
try:
257272
syntax = d['SYNTAX'][0]
@@ -302,7 +317,7 @@ def __str__(self):
302317
3:" USAGE dSAOperation",
303318
}[self.usage]
304319
)
305-
result.append(self.key_attr('X-ORIGIN',self.x_origin,quoted=1))
320+
result.append(self.key_list('X-ORIGIN',self.x_origin,quoted=1))
306321
result.append(self.key_attr('X-ORDERED',self.x_ordered,quoted=1))
307322
return '( %s )' % ''.join(result)
308323

@@ -314,7 +329,7 @@ class LDAPSyntax(SchemaElement):
314329
oid
315330
OID assigned to the LDAP syntax
316331
desc
317-
This string contains description text (DESC) of the LDAP syntax
332+
Description text (DESC) of the LDAP syntax (string, or None if missing)
318333
not_human_readable
319334
Integer flag (0 or 1) indicating whether the attribute type is marked
320335
as not human-readable (X-NOT-HUMAN-READABLE)
@@ -358,14 +373,15 @@ class MatchingRule(SchemaElement):
358373
oid
359374
OID assigned to the matching rule
360375
names
361-
This list of strings contains all NAMEs of the matching rule
376+
All NAMEs of the matching rule (tuple of strings)
362377
desc
363-
This string contains description text (DESC) of the matching rule
378+
Description text (DESC) of the matching rule
364379
obsolete
365380
Integer flag (0 or 1) indicating whether the matching rule is marked
366381
as OBSOLETE in the schema
367382
syntax
368-
String contains OID of the LDAP syntax this matching rule is usable with
383+
OID of the LDAP syntax this matching rule is usable with
384+
(string, or None if missing)
369385
"""
370386
schema_attribute = u'matchingRules'
371387
token_defaults = {
@@ -403,15 +419,15 @@ class MatchingRuleUse(SchemaElement):
403419
oid
404420
OID of the accompanying matching rule
405421
names
406-
This list of strings contains all NAMEs of the matching rule
422+
All NAMEs of the matching rule (tuple of strings)
407423
desc
408-
This string contains description text (DESC) of the matching rule
424+
Description text (DESC) of the matching rule (string, or None if missing)
409425
obsolete
410426
Integer flag (0 or 1) indicating whether the matching rule is marked
411427
as OBSOLETE in the schema
412428
applies
413-
This list of strings contains NAMEs or OIDs of attribute types
414-
for which this matching rule is used
429+
NAMEs or OIDs of attribute types for which this matching rule is used
430+
(tuple of strings)
415431
"""
416432
schema_attribute = u'matchingRuleUse'
417433
token_defaults = {
@@ -449,26 +465,29 @@ class DITContentRule(SchemaElement):
449465
oid
450466
OID of the accompanying structural object class
451467
names
452-
This list of strings contains all NAMEs of the DIT content rule
468+
All NAMEs of the DIT content rule (tuple of strings)
453469
desc
454-
This string contains description text (DESC) of the DIT content rule
470+
Description text (DESC) of the DIT content rule
471+
(string, or None if missing)
455472
obsolete
456473
Integer flag (0 or 1) indicating whether the DIT content rule is marked
457474
as OBSOLETE in the schema
458475
aux
459-
This list of strings contains NAMEs or OIDs of all auxiliary
460-
object classes usable in an entry of the object class
476+
NAMEs or OIDs of all auxiliary object classes usable in an entry of the
477+
object class (tuple of strings)
461478
must
462-
This list of strings contains NAMEs or OIDs of all attributes
463-
an entry of the object class must have which may extend the
464-
list of required attributes of the object classes of an entry
479+
NAMEs or OIDs of all attributes an entry of the object class must
480+
have, which may extend the list of required attributes of the object
481+
classes of an entry.
482+
(tuple of strings)
465483
may
466-
This list of strings contains NAMEs or OIDs of additional attributes
467-
an entry of the object class may have which may extend the
468-
list of optional attributes of the object classes of an entry
484+
NAMEs or OIDs of additional attributes an entry of the object class may
485+
have. which may extend the list of optional attributes of the object
486+
classes of an entry.
487+
(tuple of strings)
469488
nots
470-
This list of strings contains NAMEs or OIDs of attributes which
471-
may not be present in an entry of the object class
489+
NAMEs or OIDs of attributes which may not be present in an entry of the
490+
object class. (tuple of strings)
472491
"""
473492
schema_attribute = u'dITContentRules'
474493
token_defaults = {
@@ -515,17 +534,18 @@ class DITStructureRule(SchemaElement):
515534
ruleid
516535
rule ID of the DIT structure rule (only locally unique)
517536
names
518-
This list of strings contains all NAMEs of the DIT structure rule
537+
All NAMEs of the DIT structure rule (tuple of strings)
519538
desc
520-
This string contains description text (DESC) of the DIT structure rule
539+
Description text (DESC) of the DIT structure rule
540+
(string, or None if missing)
521541
obsolete
522542
Integer flag (0 or 1) indicating whether the DIT content rule is marked
523543
as OBSOLETE in the schema
524544
form
525-
List of strings with NAMEs or OIDs of associated name forms
545+
NAMEs or OIDs of associated name forms (tuple of strings)
526546
sup
527-
List of strings with NAMEs or OIDs of allowed structural object classes
528-
of superior entries in the DIT
547+
NAMEs or OIDs of allowed structural object classes
548+
of superior entries in the DIT (tuple of strings)
529549
"""
530550
schema_attribute = u'dITStructureRules'
531551

@@ -573,23 +593,22 @@ class NameForm(SchemaElement):
573593
oid
574594
OID of the name form
575595
names
576-
This list of strings contains all NAMEs of the name form
596+
All NAMEs of the name form (tuple of strings)
577597
desc
578-
This string contains description text (DESC) of the name form
598+
Description text (DESC) of the name form (string, or None if missing)
579599
obsolete
580600
Integer flag (0 or 1) indicating whether the name form is marked
581601
as OBSOLETE in the schema
582602
form
583-
List of strings with NAMEs or OIDs of associated name forms
603+
NAMEs or OIDs of associated name forms (tuple of strings)
584604
oc
585-
String with NAME or OID of structural object classes this name form
586-
is usable with
605+
NAME or OID of structural object classes this name form
606+
is usable with (string)
587607
must
588-
This list of strings contains NAMEs or OIDs of all attributes
589-
an RDN must contain
608+
NAMEs or OIDs of all attributes an RDN must contain (tuple of strings)
590609
may
591-
This list of strings contains NAMEs or OIDs of additional attributes
592-
an RDN may contain
610+
NAMEs or OIDs of additional attributes an RDN may contain
611+
(tuple of strings)
593612
"""
594613
schema_attribute = u'nameForms'
595614
token_defaults = {

0 commit comments

Comments
 (0)