rfc2251.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. #
  2. # LDAP message syntax
  3. #
  4. # ASN.1 source from:
  5. # http://www.trl.ibm.com/projects/xml/xss4j/data/asn1/grammars/ldap.asn
  6. #
  7. # Sample captures from:
  8. # http://wiki.wireshark.org/SampleCaptures/
  9. #
  10. from pyasn1.type import tag, namedtype, namedval, univ, constraint,char,useful
  11. from pyasn1.codec.der import decoder, encoder
  12. maxInt = univ.Integer(2147483647)
  13. class LDAPString(univ.OctetString): pass
  14. class LDAPOID(univ.OctetString): pass
  15. class LDAPDN(LDAPString): pass
  16. class RelativeLDAPDN(LDAPString): pass
  17. class AttributeType(LDAPString): pass
  18. class AttributeDescription(LDAPString): pass
  19. class AttributeDescriptionList(univ.SequenceOf):
  20. componentType = AttributeDescription()
  21. class AttributeValue(univ.OctetString): pass
  22. class AssertionValue(univ.OctetString): pass
  23. class AttributeValueAssertion(univ.Sequence):
  24. componentType = namedtype.NamedTypes(
  25. namedtype.NamedType('attributeDesc', AttributeDescription()),
  26. namedtype.NamedType('assertionValue', AssertionValue())
  27. )
  28. class Attribute(univ.Sequence):
  29. componentType = namedtype.NamedTypes(
  30. namedtype.NamedType('type', AttributeDescription()),
  31. namedtype.NamedType('vals', univ.SetOf(componentType=AttributeValue()))
  32. )
  33. class MatchingRuleId(LDAPString): pass
  34. class Control(univ.Sequence):
  35. componentType = namedtype.NamedTypes(
  36. namedtype.NamedType('controlType', LDAPOID()),
  37. namedtype.DefaultedNamedType('criticality', univ.Boolean('False')),
  38. namedtype.OptionalNamedType('controlValue', univ.OctetString())
  39. )
  40. class Controls(univ.SequenceOf):
  41. componentType = Control()
  42. class LDAPURL(LDAPString): pass
  43. class Referral(univ.SequenceOf):
  44. componentType = LDAPURL()
  45. class SaslCredentials(univ.Sequence):
  46. componentType = namedtype.NamedTypes(
  47. namedtype.NamedType('mechanism', LDAPString()),
  48. namedtype.OptionalNamedType('credentials', univ.OctetString())
  49. )
  50. class AuthenticationChoice(univ.Choice):
  51. componentType = namedtype.NamedTypes(
  52. namedtype.NamedType('simple', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  53. namedtype.NamedType('reserved-1', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  54. namedtype.NamedType('reserved-2', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  55. namedtype.NamedType('sasl', SaslCredentials().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
  56. )
  57. class BindRequest(univ.Sequence):
  58. tagSet = univ.Sequence.tagSet.tagImplicitly(
  59. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 0)
  60. )
  61. componentType = namedtype.NamedTypes(
  62. namedtype.NamedType('version', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, 127))),
  63. namedtype.NamedType('name', LDAPDN()),
  64. namedtype.NamedType('authentication', AuthenticationChoice())
  65. )
  66. class PartialAttributeList(univ.SequenceOf):
  67. componentType = univ.Sequence(componentType=namedtype.NamedTypes(namedtype.NamedType('type', AttributeDescription()), namedtype.NamedType('vals', univ.SetOf(componentType=AttributeValue()))))
  68. class SearchResultEntry(univ.Sequence):
  69. tagSet = univ.Sequence.tagSet.tagImplicitly(
  70. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 4)
  71. )
  72. componentType = namedtype.NamedTypes(
  73. namedtype.NamedType('objectName', LDAPDN()),
  74. namedtype.NamedType('attributes', PartialAttributeList())
  75. )
  76. class MatchingRuleAssertion(univ.Sequence):
  77. componentType = namedtype.NamedTypes(
  78. namedtype.OptionalNamedType('matchingRule', MatchingRuleId().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  79. namedtype.OptionalNamedType('type', AttributeDescription().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  80. namedtype.NamedType('matchValue', AssertionValue().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  81. namedtype.DefaultedNamedType('dnAttributes', univ.Boolean('False').subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)))
  82. )
  83. class SubstringFilter(univ.Sequence):
  84. componentType = namedtype.NamedTypes(
  85. namedtype.NamedType('type', AttributeDescription()),
  86. namedtype.NamedType('substrings', univ.SequenceOf(componentType=univ.Choice(componentType=namedtype.NamedTypes(namedtype.NamedType('initial', LDAPString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('any', LDAPString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.NamedType('final', LDAPString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))))))
  87. )
  88. # Ugly hack to handle recursive Filter reference (up to 3-levels deep).
  89. class Filter3(univ.Choice):
  90. componentType = namedtype.NamedTypes(
  91. namedtype.NamedType('equalityMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
  92. namedtype.NamedType('substrings', SubstringFilter().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
  93. namedtype.NamedType('greaterOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
  94. namedtype.NamedType('lessOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 6))),
  95. namedtype.NamedType('present', AttributeDescription().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
  96. namedtype.NamedType('approxMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 8))),
  97. namedtype.NamedType('extensibleMatch', MatchingRuleAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 9)))
  98. )
  99. class Filter2(univ.Choice):
  100. componentType = namedtype.NamedTypes(
  101. namedtype.NamedType('and', univ.SetOf(componentType=Filter3()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  102. namedtype.NamedType('or', univ.SetOf(componentType=Filter3()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
  103. namedtype.NamedType('not', Filter3().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
  104. namedtype.NamedType('equalityMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
  105. namedtype.NamedType('substrings', SubstringFilter().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
  106. namedtype.NamedType('greaterOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
  107. namedtype.NamedType('lessOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 6))),
  108. namedtype.NamedType('present', AttributeDescription().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
  109. namedtype.NamedType('approxMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 8))),
  110. namedtype.NamedType('extensibleMatch', MatchingRuleAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 9)))
  111. )
  112. class Filter(univ.Choice):
  113. componentType = namedtype.NamedTypes(
  114. namedtype.NamedType('and', univ.SetOf(componentType=Filter2()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  115. namedtype.NamedType('or', univ.SetOf(componentType=Filter2()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
  116. namedtype.NamedType('not', Filter2().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
  117. namedtype.NamedType('equalityMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
  118. namedtype.NamedType('substrings', SubstringFilter().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
  119. namedtype.NamedType('greaterOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
  120. namedtype.NamedType('lessOrEqual', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 6))),
  121. namedtype.NamedType('present', AttributeDescription().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
  122. namedtype.NamedType('approxMatch', AttributeValueAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 8))),
  123. namedtype.NamedType('extensibleMatch', MatchingRuleAssertion().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 9)))
  124. )
  125. # End of Filter hack
  126. class SearchRequest(univ.Sequence):
  127. tagSet = univ.Sequence.tagSet.tagImplicitly(
  128. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 3)
  129. )
  130. componentType = namedtype.NamedTypes(
  131. namedtype.NamedType('baseObject', LDAPDN()),
  132. namedtype.NamedType('scope', univ.Enumerated(namedValues=namedval.NamedValues(('baseObject', 0), ('singleLevel', 1), ('wholeSubtree', 2)))),
  133. namedtype.NamedType('derefAliases', univ.Enumerated(namedValues=namedval.NamedValues(('neverDerefAliases', 0), ('derefInSearching', 1), ('derefFindingBaseObj', 2), ('derefAlways', 3)))),
  134. namedtype.NamedType('sizeLimit', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, maxInt))),
  135. namedtype.NamedType('timeLimit', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, maxInt))),
  136. namedtype.NamedType('typesOnly', univ.Boolean()),
  137. namedtype.NamedType('filter', Filter()),
  138. namedtype.NamedType('attributes', AttributeDescriptionList())
  139. )
  140. class UnbindRequest(univ.Null):
  141. tagSet = univ.Sequence.tagSet.tagImplicitly(
  142. tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 2)
  143. )
  144. class BindResponse(univ.Sequence):
  145. tagSet = univ.Sequence.tagSet.tagImplicitly(
  146. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1)
  147. )
  148. componentType = namedtype.NamedTypes(
  149. namedtype.NamedType('resultCode', univ.Enumerated(namedValues=namedval.NamedValues(('success', 0), ('operationsError', 1), ('protocolError', 2), ('timeLimitExceeded', 3), ('sizeLimitExceeded', 4), ('compareFalse', 5), ('compareTrue', 6), ('authMethodNotSupported', 7), ('strongAuthRequired', 8), ('reserved-9', 9), ('referral', 10), ('adminLimitExceeded', 11), ('unavailableCriticalExtension', 12), ('confidentialityRequired', 13), ('saslBindInProgress', 14), ('noSuchAttribute', 16), ('undefinedAttributeType', 17), ('inappropriateMatching', 18), ('constraintViolation', 19), ('attributeOrValueExists', 20), ('invalidAttributeSyntax', 21), ('noSuchObject', 32), ('aliasProblem', 33), ('invalidDNSyntax', 34), ('reserved-35', 35), ('aliasDereferencingProblem', 36), ('inappropriateAuthentication', 48), ('invalidCredentials', 49), ('insufficientAccessRights', 50), ('busy', 51), ('unavailable', 52), ('unwillingToPerform', 53), ('loopDetect', 54), ('namingViolation', 64), ('objectClassViolation', 65), ('notAllowedOnNonLeaf', 66), ('notAllowedOnRDN', 67), ('entryAlreadyExists', 68), ('objectClassModsProhibited', 69), ('reserved-70', 70), ('affectsMultipleDSAs', 71), ('other', 80), ('reserved-81', 81), ('reserved-82', 82), ('reserved-83', 83), ('reserved-84', 84), ('reserved-85', 85), ('reserved-86', 86), ('reserved-87', 87), ('reserved-88', 88), ('reserved-89', 89), ('reserved-90', 90)))),
  150. namedtype.NamedType('matchedDN', LDAPDN()),
  151. namedtype.NamedType('errorMessage', LDAPString()),
  152. namedtype.OptionalNamedType('referral', Referral().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
  153. namedtype.OptionalNamedType('serverSaslCreds', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 7)))
  154. )
  155. class LDAPResult(univ.Sequence):
  156. componentType = namedtype.NamedTypes(
  157. namedtype.NamedType('resultCode', univ.Enumerated(namedValues=namedval.NamedValues(('success', 0), ('operationsError', 1), ('protocolError', 2), ('timeLimitExceeded', 3), ('sizeLimitExceeded', 4), ('compareFalse', 5), ('compareTrue', 6), ('authMethodNotSupported', 7), ('strongAuthRequired', 8), ('reserved-9', 9), ('referral', 10), ('adminLimitExceeded', 11), ('unavailableCriticalExtension', 12), ('confidentialityRequired', 13), ('saslBindInProgress', 14), ('noSuchAttribute', 16), ('undefinedAttributeType', 17), ('inappropriateMatching', 18), ('constraintViolation', 19), ('attributeOrValueExists', 20), ('invalidAttributeSyntax', 21), ('noSuchObject', 32), ('aliasProblem', 33), ('invalidDNSyntax', 34), ('reserved-35', 35), ('aliasDereferencingProblem', 36), ('inappropriateAuthentication', 48), ('invalidCredentials', 49), ('insufficientAccessRights', 50), ('busy', 51), ('unavailable', 52), ('unwillingToPerform', 53), ('loopDetect', 54), ('namingViolation', 64), ('objectClassViolation', 65), ('notAllowedOnNonLeaf', 66), ('notAllowedOnRDN', 67), ('entryAlreadyExists', 68), ('objectClassModsProhibited', 69), ('reserved-70', 70), ('affectsMultipleDSAs', 71), ('other', 80), ('reserved-81', 81), ('reserved-82', 82), ('reserved-83', 83), ('reserved-84', 84), ('reserved-85', 85), ('reserved-86', 86), ('reserved-87', 87), ('reserved-88', 88), ('reserved-89', 89), ('reserved-90', 90)))),
  158. namedtype.NamedType('matchedDN', LDAPDN()),
  159. namedtype.NamedType('errorMessage', LDAPString()),
  160. namedtype.OptionalNamedType('referral', Referral().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)))
  161. )
  162. class SearchResultReference(univ.SequenceOf):
  163. tagSet = univ.Sequence.tagSet.tagImplicitly(
  164. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 19)
  165. )
  166. componentType = LDAPURL()
  167. class SearchResultDone(LDAPResult):
  168. tagSet = univ.Sequence.tagSet.tagImplicitly(
  169. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 5)
  170. )
  171. class AttributeTypeAndValues(univ.Sequence):
  172. componentType = namedtype.NamedTypes(
  173. namedtype.NamedType('type', AttributeDescription()),
  174. namedtype.NamedType('vals', univ.SetOf(componentType=AttributeValue()))
  175. )
  176. class ModifyRequest(univ.Sequence):
  177. tagSet = univ.Sequence.tagSet.tagImplicitly(
  178. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 6)
  179. )
  180. componentType = namedtype.NamedTypes(
  181. namedtype.NamedType('object', LDAPDN()),
  182. namedtype.NamedType('modification', univ.SequenceOf(componentType=univ.Sequence(componentType=namedtype.NamedTypes(namedtype.NamedType('operation', univ.Enumerated(namedValues=namedval.NamedValues(('add', 0), ('delete', 1), ('replace', 2)))), namedtype.NamedType('modification', AttributeTypeAndValues())))))
  183. )
  184. class ModifyResponse(LDAPResult):
  185. tagSet = univ.Sequence.tagSet.tagImplicitly(
  186. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 7)
  187. )
  188. class AttributeList(univ.SequenceOf):
  189. componentType = univ.Sequence(componentType=namedtype.NamedTypes(namedtype.NamedType('type', AttributeDescription()), namedtype.NamedType('vals', univ.SetOf(componentType=AttributeValue()))))
  190. class AddRequest(univ.Sequence):
  191. tagSet = univ.Sequence.tagSet.tagImplicitly(
  192. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 8)
  193. )
  194. componentType = namedtype.NamedTypes(
  195. namedtype.NamedType('entry', LDAPDN()),
  196. namedtype.NamedType('attributes', AttributeList())
  197. )
  198. class AddResponse(LDAPResult):
  199. tagSet = univ.Sequence.tagSet.tagImplicitly(
  200. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 9)
  201. )
  202. class DelRequest(LDAPResult):
  203. tagSet = univ.Sequence.tagSet.tagImplicitly(
  204. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 10)
  205. )
  206. class DelResponse(LDAPResult):
  207. tagSet = univ.Sequence.tagSet.tagImplicitly(
  208. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 11)
  209. )
  210. class ModifyDNRequest(univ.Sequence):
  211. tagSet = univ.Sequence.tagSet.tagImplicitly(
  212. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 12)
  213. )
  214. componentType = namedtype.NamedTypes(
  215. namedtype.NamedType('entry', LDAPDN()),
  216. namedtype.NamedType('newrdn', RelativeLDAPDN()),
  217. namedtype.NamedType('deleteoldrdn', univ.Boolean()),
  218. namedtype.OptionalNamedType('newSuperior', LDAPDN().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  219. )
  220. class ModifyDNResponse(LDAPResult):
  221. tagSet = univ.Sequence.tagSet.tagImplicitly(
  222. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 13)
  223. )
  224. class CompareRequest(univ.Sequence):
  225. tagSet = univ.Sequence.tagSet.tagImplicitly(
  226. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 14)
  227. )
  228. componentType = namedtype.NamedTypes(
  229. namedtype.NamedType('entry', LDAPDN()),
  230. namedtype.NamedType('ava', AttributeValueAssertion())
  231. )
  232. class CompareResponse(LDAPResult):
  233. tagSet = univ.Sequence.tagSet.tagImplicitly(
  234. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 15)
  235. )
  236. class AbandonRequest(LDAPResult):
  237. tagSet = univ.Sequence.tagSet.tagImplicitly(
  238. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 16)
  239. )
  240. class ExtendedRequest(univ.Sequence):
  241. tagSet = univ.Sequence.tagSet.tagImplicitly(
  242. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 23)
  243. )
  244. componentType = namedtype.NamedTypes(
  245. namedtype.NamedType('requestName', LDAPOID().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  246. namedtype.OptionalNamedType('requestValue', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  247. )
  248. class ExtendedResponse(univ.Sequence):
  249. tagSet = univ.Sequence.tagSet.tagImplicitly(
  250. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 24)
  251. )
  252. componentType = namedtype.NamedTypes(
  253. namedtype.NamedType('resultCode', univ.Enumerated(namedValues=namedval.NamedValues(('success', 0), ('operationsError', 1), ('protocolError', 2), ('timeLimitExceeded', 3), ('sizeLimitExceeded', 4), ('compareFalse', 5), ('compareTrue', 6), ('authMethodNotSupported', 7), ('strongAuthRequired', 8), ('reserved-9', 9), ('referral', 10), ('adminLimitExceeded', 11), ('unavailableCriticalExtension', 12), ('confidentialityRequired', 13), ('saslBindInProgress', 14), ('noSuchAttribute', 16), ('undefinedAttributeType', 17), ('inappropriateMatching', 18), ('constraintViolation', 19), ('attributeOrValueExists', 20), ('invalidAttributeSyntax', 21), ('noSuchObject', 32), ('aliasProblem', 33), ('invalidDNSyntax', 34), ('reserved-35', 35), ('aliasDereferencingProblem', 36), ('inappropriateAuthentication', 48), ('invalidCredentials', 49), ('insufficientAccessRights', 50), ('busy', 51), ('unavailable', 52), ('unwillingToPerform', 53), ('loopDetect', 54), ('namingViolation', 64), ('objectClassViolation', 65), ('notAllowedOnNonLeaf', 66), ('notAllowedOnRDN', 67), ('entryAlreadyExists', 68), ('objectClassModsProhibited', 69), ('reserved-70', 70), ('affectsMultipleDSAs', 71), ('other', 80), ('reserved-81', 81), ('reserved-82', 82), ('reserved-83', 83), ('reserved-84', 84), ('reserved-85', 85), ('reserved-86', 86), ('reserved-87', 87), ('reserved-88', 88), ('reserved-89', 89), ('reserved-90', 90)))),
  254. namedtype.NamedType('matchedDN', LDAPDN()),
  255. namedtype.NamedType('errorMessage', LDAPString()),
  256. namedtype.OptionalNamedType('referral', Referral().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
  257. namedtype.OptionalNamedType('responseName', LDAPOID().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 10))),
  258. namedtype.OptionalNamedType('response', univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 11)))
  259. )
  260. class MessageID(univ.Integer):
  261. subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint(
  262. 0, maxInt
  263. )
  264. class LDAPMessage(univ.Sequence):
  265. componentType = namedtype.NamedTypes(
  266. namedtype.NamedType('messageID', MessageID()),
  267. namedtype.NamedType('protocolOp', univ.Choice(componentType=namedtype.NamedTypes(namedtype.NamedType('bindRequest', BindRequest()), namedtype.NamedType('bindResponse', BindResponse()), namedtype.NamedType('unbindRequest', UnbindRequest()), namedtype.NamedType('searchRequest', SearchRequest()), namedtype.NamedType('searchResEntry', SearchResultEntry()), namedtype.NamedType('searchResDone', SearchResultDone()), namedtype.NamedType('searchResRef', SearchResultReference()), namedtype.NamedType('modifyRequest', ModifyRequest()), namedtype.NamedType('modifyResponse', ModifyResponse()), namedtype.NamedType('addRequest', AddRequest()), namedtype.NamedType('addResponse', AddResponse()), namedtype.NamedType('delRequest', DelRequest()), namedtype.NamedType('delResponse', DelResponse()), namedtype.NamedType('modDNRequest', ModifyDNRequest()), namedtype.NamedType('modDNResponse', ModifyDNResponse()), namedtype.NamedType('compareRequest', CompareRequest()), namedtype.NamedType('compareResponse', CompareResponse()), namedtype.NamedType('abandonRequest', AbandonRequest()), namedtype.NamedType('extendedReq', ExtendedRequest()), namedtype.NamedType('extendedResp', ExtendedResponse())))),
  268. namedtype.OptionalNamedType('controls', Controls().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
  269. )