Esempio n. 1
0
 def __init__(self, objectName, attributes, tag=None):
     LDAPProtocolResponse.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     assert objectName is not None
     assert attributes is not None
     self.objectName=objectName
     self.attributes=attributes
Esempio n. 2
0
 def __init__(self, objectName, attributes, tag=None):
     LDAPProtocolResponse.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     assert objectName is not None
     assert attributes is not None
     self.objectName = objectName
     self.attributes = attributes
Esempio n. 3
0
 def __init__(self, entry, ava, tag=None):
     LDAPProtocolRequest.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     assert entry is not None
     assert ava is not None
     self.entry = entry
     self.ava = ava
Esempio n. 4
0
    def __init__(self,
                 entry,
                 newrdn,
                 deleteoldrdn,
                 newSuperior=None,
                 tag=None):
        """
        Initialize the object

        Example usage::

                l=LDAPModifyDNRequest(entry='cn=foo,dc=example,dc=com',
                                      newrdn='someAttr=value',
                                      deleteoldrdn=0)
        """

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        assert entry is not None
        assert newrdn is not None
        assert deleteoldrdn is not None
        self.entry = entry
        self.newrdn = newrdn
        self.deleteoldrdn = deleteoldrdn
        self.newSuperior = newSuperior
Esempio n. 5
0
    def __init__(self,
                 baseObject=None,
                 scope=None,
                 derefAliases=None,
                 sizeLimit=None,
                 timeLimit=None,
                 typesOnly=None,
                 filter=None,
                 attributes=None,
                 tag=None):
        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)

        if baseObject is not None:
            self.baseObject = baseObject
        if scope is not None:
            self.scope = scope
        if derefAliases is not None:
            self.derefAliases = derefAliases
        if sizeLimit is not None:
            self.sizeLimit = sizeLimit
        if timeLimit is not None:
            self.timeLimit = timeLimit
        if typesOnly is not None:
            self.typesOnly = typesOnly
        if filter is not None:
            self.filter = filter
        if attributes is not None:
            self.attributes = attributes
Esempio n. 6
0
 def __init__(self, entry, ava, tag=None):
     LDAPProtocolRequest.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     assert entry is not None
     assert ava is not None
     self.entry = entry
     self.ava = ava
Esempio n. 7
0
    def __init__(self,
                 matchingRule=None,
                 type=None,
                 matchValue=None,
                 dnAttributes=None,
                 tag=None):
        BERSequence.__init__(self, value=[], tag=tag)
        assert matchValue is not None
        if isinstance(matchingRule, basestring):
            matchingRule = LDAPMatchingRuleAssertion_matchingRule(matchingRule)

        if isinstance(type, basestring):
            type = LDAPMatchingRuleAssertion_type(type)

        if isinstance(matchValue, basestring):
            matchValue = LDAPMatchingRuleAssertion_matchValue(matchValue)

        if isinstance(dnAttributes, bool):
            dnAttributes = LDAPMatchingRuleAssertion_dnAttributes(dnAttributes)

        self.matchingRule = matchingRule
        self.type = type
        self.matchValue = matchValue
        self.dnAttributes = dnAttributes
        if not self.dnAttributes:
            self.dnAttributes = None
Esempio n. 8
0
 def __str__(self):
     return str(
         BERSequence([
             LDAPString(self.entry),
             BERSequence(map(BERSequence, self.attributes)),
         ],
                     tag=self.tag))
Esempio n. 9
0
    def __init__(self,
                 baseObject=None,
                 scope=None,
                 derefAliases=None,
                 sizeLimit=None,
                 timeLimit=None,
                 typesOnly=None,
                 filter=None,
                 attributes=None,
                 tag=None):
        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)

        if baseObject is not None:
            self.baseObject=baseObject
        if scope is not None:
            self.scope=scope
        if derefAliases is not None:
            self.derefAliases=derefAliases
        if sizeLimit is not None:
            self.sizeLimit=sizeLimit
        if timeLimit is not None:
            self.timeLimit=timeLimit
        if typesOnly is not None:
            self.typesOnly=typesOnly
        if filter is not None:
            self.filter=filter
        if attributes is not None:
            self.attributes=attributes
Esempio n. 10
0
 def __init__(self,
              controlType, criticality=None, controlValue=None,
              id=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert controlType is not None
     self.controlType = controlType
     self.criticality = criticality
     self.controlValue = controlValue
Esempio n. 11
0
 def __init__(self, value=None, controls=None, id=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert value is not None
     self.id = id
     if self.id is None:
         self.id = alloc_ldap_message_id()
     self.value = value
     self.controls = controls
Esempio n. 12
0
 def __init__(self, requestName=None, requestValue=None, tag=None):
     LDAPProtocolRequest.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     assert requestName is not None
     assert isinstance(requestName, basestring)
     assert requestValue is None or isinstance(requestValue, basestring)
     self.requestName = requestName
     self.requestValue = requestValue
Esempio n. 13
0
 def __init__(self,
              controlType, criticality=None, controlValue=None,
              id=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert controlType is not None
     self.controlType = controlType
     self.criticality = criticality
     self.controlValue = controlValue
Esempio n. 14
0
 def __init__(self, value=None, controls=None, id=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert value is not None
     self.id=id
     if self.id is None:
         self.id=alloc_ldap_message_id()
     self.value=value
     self.controls = controls
Esempio n. 15
0
 def __init__(self, requestName, requestValue=None,
              tag=None):
     LDAPProtocolRequest.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     assert requestName is not None
     assert isinstance(requestName, basestring)
     self.requestName=requestName
     self.requestValue=requestValue
Esempio n. 16
0
 def __init__(self, matchingRule=None, type=None, matchValue=None, dnAttributes=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert matchValue is not None
     self.matchingRule=matchingRule
     self.type=type
     self.matchValue=matchValue
     self.dnAttributes=dnAttributes
     if not self.dnAttributes:
         self.dnAttributes=None
Esempio n. 17
0
 def __str__(self):
     if not self.sasl:
         auth_ber = BEROctetString(self.auth, tag=CLASS_CONTEXT|0)
     else:
         auth_ber = BERSequence([BEROctetString(self.auth[0]), BEROctetString(self.auth[1])], tag=CLASS_CONTEXT|3)
     return str(BERSequence([
         BERInteger(self.version),
         BEROctetString(self.dn),
         auth_ber,
         ], tag=self.tag))
Esempio n. 18
0
 def __init__(self,
              attributeDesc=None,
              assertionValue=None,
              tag=None,
              escaper=escape):
     BERSequence.__init__(self, value=[], tag=tag)
     assert attributeDesc is not None
     self.attributeDesc = attributeDesc
     self.assertionValue = assertionValue
     self.escaper = escaper
Esempio n. 19
0
 def __init__(self, version=None, dn=None, auth=None, tag=None):
     LDAPProtocolRequest.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     self.version = version
     if self.version is None:
         self.version = 3
     self.dn = dn
     if self.dn is None:
         self.dn = ''
     self.auth = auth
     if self.auth is None:
         self.auth = ''
Esempio n. 20
0
 def __init__(self, version=None, dn=None, auth=None, tag=None):
     LDAPProtocolRequest.__init__(self)
     BERSequence.__init__(self, [], tag=tag)
     self.version=version
     if self.version is None:
         self.version=3
     self.dn=dn
     if self.dn is None:
         self.dn=''
     self.auth=auth
     if self.auth is None:
         self.auth=''
Esempio n. 21
0
 def __init__(self, resultCode=None, matchedDN=None, errorMessage=None, referral=None, serverSaslCreds=None, tag=None):
     LDAPProtocolResponse.__init__(self)
     BERSequence.__init__(self, value=[], tag=tag)
     assert resultCode is not None
     self.resultCode=resultCode
     if matchedDN is None:
         matchedDN=''
     self.matchedDN=matchedDN
     if errorMessage is None:
         errorMessage=''
     self.errorMessage=errorMessage
     self.referral=referral
     self.serverSaslCreds=serverSaslCreds
Esempio n. 22
0
 def __init__(self, resultCode=None, matchedDN=None, errorMessage=None, referral=None, serverSaslCreds=None, tag=None):
     LDAPProtocolResponse.__init__(self)
     BERSequence.__init__(self, value=[], tag=tag)
     assert resultCode is not None
     self.resultCode=resultCode
     if matchedDN is None:
         matchedDN=''
     self.matchedDN=matchedDN
     if errorMessage is None:
         errorMessage=''
     self.errorMessage=errorMessage
     self.referral=referral
     self.serverSaslCreds=serverSaslCreds
Esempio n. 23
0
 def __init__(self,
              matchingRule=None,
              type=None,
              matchValue=None,
              dnAttributes=None,
              tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert matchValue is not None
     self.matchingRule = matchingRule
     self.type = type
     self.matchValue = matchValue
     self.dnAttributes = dnAttributes
     if not self.dnAttributes:
         self.dnAttributes = None
Esempio n. 24
0
 def __str__(self):
     self.data=[LDAPOID(self.controlType)]
     if self.criticality is not None:
         self.data.append(BERBoolean(self.criticality))
     if self.controlValue is not None:
         self.data.append(BEROctetString(self.controlValue))
     return BERSequence.__str__(self)
Esempio n. 25
0
 def __str__(self):
     return str(
         BERSequence(filter(lambda x: x is not None, [
             self.matchingRule, self.type, self.matchValue,
             self.dnAttributes
         ]),
                     tag=self.tag))
Esempio n. 26
0
 def __str__(self):
     self.data = [LDAPOID(self.controlType)]
     if self.criticality is not None:
         self.data.append(BERBoolean(self.criticality))
     if self.controlValue is not None:
         self.data.append(BEROctetString(self.controlValue))
     return BERSequence.__str__(self)
Esempio n. 27
0
 def __str__(self):
     assert self.referral is None #TODO
     return str(BERSequence([
         BEREnumerated(self.resultCode),
         BEROctetString(self.matchedDN),
         BEROctetString(self.errorMessage),
         #TODO referral [3] Referral OPTIONAL
         ], tag=self.tag))
Esempio n. 28
0
 def __str__(self):
     return str(
         BERSequence([
             BERInteger(self.version),
             BEROctetString(self.dn),
             BEROctetString(self.auth, tag=CLASS_CONTEXT | 0),
         ],
                     tag=self.tag))
Esempio n. 29
0
 def __str__(self):
     return str(BERSequence([
         BEROctetString(self.objectName),
         BERSequence(map(lambda (attr,li):
                         BERSequence([BEROctetString(attr),
                                      BERSet(map(BEROctetString,
                                                 li))]),
                         self.attributes)),
         ], tag=self.tag))
Esempio n. 30
0
 def __str__(self):
     l = [
         LDAPString(self.entry),
         LDAPString(self.newrdn),
         BERBoolean(self.deleteoldrdn),
     ]
     if self.newSuperior is not None:
         l.append(LDAPString(self.newSuperior, tag=CLASS_CONTEXT | 0))
     return str(BERSequence(l, tag=self.tag))
Esempio n. 31
0
    def __init__(self, version=None, dn=None, auth=None, tag=None, sasl=False):
        """Constructor for LDAP Bind Request

        For sasl=False, pass a string password for 'auth'
        For sasl=True, pass a tuple of (mechanism, credentials) for 'auth'"""

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        self.version=version
        if self.version is None:
            self.version=3
        self.dn=dn
        if self.dn is None:
            self.dn=''
        self.auth=auth
        if self.auth is None:
            self.auth=''
            assert(not sasl)
        self.sasl=sasl
Esempio n. 32
0
    def __init__(self, version=None, dn=None, auth=None, tag=None, sasl=False):
        """Constructor for LDAP Bind Request

        For sasl=False, pass a string password for 'auth'
        For sasl=True, pass a tuple of (mechanism, credentials) for 'auth'"""

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        self.version = version
        if self.version is None:
            self.version = 3
        self.dn = dn
        if self.dn is None:
            self.dn = ''
        self.auth = auth
        if self.auth is None:
            self.auth = ''
            assert (not sasl)
        self.sasl = sasl
Esempio n. 33
0
    def __init__(self, object=None, modification=None, tag=None):
        """
        Initialize the object

        Example usage::

                l = LDAPModifyRequest(
                    object='cn=foo,dc=example,dc=com',
                    modification=[

                      BERSequence([
                        BEREnumerated(0),
                        BERSequence([
                          LDAPAttributeDescription('attr1'),
                          BERSet([
                            LDAPString('value1'),
                            LDAPString('value2'),
                            ]),
                          ]),
                        ]),

                      BERSequence([
                        BEREnumerated(1),
                        BERSequence([
                          LDAPAttributeDescription('attr2'),
                          ]),
                        ]),

                    ])

        But more likely you just want to say::

        	mod = delta.ModifyOp('cn=foo,dc=example,dc=com',
                    [delta.Add('attr1', ['value1', 'value2']),
                     delta.Delete('attr1', ['value1', 'value2'])])
        	l = mod.asLDAP()
        """

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        self.object = object
        self.modification = modification
Esempio n. 34
0
    def __init__(self, object=None, modification=None, tag=None):
        """
        Initialize the object

        Example usage::

                l = LDAPModifyRequest(
                    object='cn=foo,dc=example,dc=com',
                    modification=[

                      BERSequence([
                        BEREnumerated(0),
                        BERSequence([
                          LDAPAttributeDescription('attr1'),
                          BERSet([
                            LDAPString('value1'),
                            LDAPString('value2'),
                            ]),
                          ]),
                        ]),

                      BERSequence([
                        BEREnumerated(1),
                        BERSequence([
                          LDAPAttributeDescription('attr2'),
                          ]),
                        ]),

                    ])

        But more likely you just want to say::

        	mod = delta.ModifyOp('cn=foo,dc=example,dc=com',
                    [delta.Add('attr1', ['value1', 'value2']),
                     delta.Delete('attr1', ['value1', 'value2'])])
        	l = mod.asLDAP()
        """

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        self.object=object
        self.modification=modification
Esempio n. 35
0
 def __str__(self):
     return str(BERSequence([
         BEROctetString(self.baseObject),
         BEREnumerated(self.scope),
         BEREnumerated(self.derefAliases),
         BERInteger(self.sizeLimit),
         BERInteger(self.timeLimit),
         BERBoolean(self.typesOnly),
         self.filter,
         BERSequenceOf(map(BEROctetString, self.attributes)),
         ], tag=self.tag))
Esempio n. 36
0
 def __str__(self):
     assert self.referral is None #TODO
     l=[BEREnumerated(self.resultCode),
        BEROctetString(self.matchedDN),
        BEROctetString(self.errorMessage),
        #TODO referral [3] Referral OPTIONAL
        ]
     if self.responseName is not None:
         l.append(LDAPOID(self.responseName, tag=CLASS_CONTEXT|0x0a))
     if self.response is not None:
         l.append(BEROctetString(self.response, tag=CLASS_CONTEXT|0x0b))
     return str(BERSequence(l, tag=self.tag))
Esempio n. 37
0
    def __init__(self, entry, newrdn, deleteoldrdn, newSuperior=None,
                 tag=None):
        """
        Initialize the object

        Example usage::

                l=LDAPModifyDNRequest(entry='cn=foo,dc=example,dc=com',
                                      newrdn='someAttr=value',
                                      deleteoldrdn=0)
        """

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        assert entry is not None
        assert newrdn is not None
        assert deleteoldrdn is not None
        self.entry=entry
        self.newrdn=newrdn
        self.deleteoldrdn=deleteoldrdn
        self.newSuperior=newSuperior
Esempio n. 38
0
    def __init__(self, entry=None, attributes=None, tag=None):
        """
        Initialize the object

        Example usage::

                l=LDAPAddRequest(entry='cn=foo,dc=example,dc=com',
                        attributes=[(LDAPAttributeDescription("attrFoo"),
                             BERSet(value=(
                                 LDAPAttributeValue("value1"),
                                 LDAPAttributeValue("value2"),
                             ))),
                             (LDAPAttributeDescription("attrBar"),
                             BERSet(value=(
                                 LDAPAttributeValue("value1"),
                                 LDAPAttributeValue("value2"),
                             ))),
                             ])
"""

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        self.entry=entry
        self.attributes=attributes
Esempio n. 39
0
    def __init__(self, entry=None, attributes=None, tag=None):
        """
        Initialize the object

        Example usage::

                l=LDAPAddRequest(entry='cn=foo,dc=example,dc=com',
                        attributes=[(LDAPAttributeDescription("attrFoo"),
                             BERSet(value=(
                                 LDAPAttributeValue("value1"),
                                 LDAPAttributeValue("value2"),
                             ))),
                             (LDAPAttributeDescription("attrBar"),
                             BERSet(value=(
                                 LDAPAttributeValue("value1"),
                                 LDAPAttributeValue("value2"),
                             ))),
                             ])
"""

        LDAPProtocolRequest.__init__(self)
        BERSequence.__init__(self, [], tag=tag)
        self.entry = entry
        self.attributes = attributes
Esempio n. 40
0
    def __init__(self, requestName=None,
                 userIdentity=None, oldPasswd=None, newPasswd=None,
                 tag=None):
        assert (requestName is None
                or requestName == self.oid), \
                '%s requestName was %s instead of %s' \
                % (self.__class__.__name__, requestName, self.oid)
        #TODO genPasswd

        l=[]
        if userIdentity is not None:
            l.append(LDAPPasswordModifyRequest_userIdentity(userIdentity))
        if oldPasswd is not None:
            l.append(LDAPPasswordModifyRequest_oldPasswd(oldPasswd))
        if newPasswd is not None:
            l.append(LDAPPasswordModifyRequest_newPasswd(newPasswd))
        LDAPExtendedRequest.__init__(
            self,
            requestName=self.oid,
            requestValue=str(BERSequence(l)),
            tag=tag)
Esempio n. 41
0
 def __init__(self, type=None, substrings=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert type is not None
     assert substrings is not None
     self.type=type
     self.substrings=substrings
Esempio n. 42
0
 def __init__(self, attributeDesc=None, assertionValue=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert attributeDesc is not None
     self.attributeDesc=attributeDesc
     self.assertionValue=assertionValue
Esempio n. 43
0
 def __str__(self):
     l = [LDAPOID(self.requestName, tag=CLASS_CONTEXT | 0)]
     if self.requestValue is not None:
         l.append(
             BEROctetString(str(self.requestValue), tag=CLASS_CONTEXT | 1))
     return str(BERSequence(l, tag=self.tag))
Esempio n. 44
0
 def __str__(self):
     return str(
         BERSequence([self.attributeDesc, self.assertionValue],
                     tag=self.tag))
Esempio n. 45
0
 def __init__(self, type=None, substrings=None, tag=None):
     BERSequence.__init__(self, value=[], tag=tag)
     assert type is not None
     assert substrings is not None
     self.type = type
     self.substrings = substrings
Esempio n. 46
0
 def __str__(self):
     return str(
         BERSequence([LDAPString(self.type),
                      BERSequence(self.substrings)],
                     tag=self.tag))