Пример #1
0
 def handleSearchResults(l):
     if len(l) == 0:
         raise ldaperrors.LDAPOther("No such DN")
     elif len(l) == 1:
         o = l[0]
         assert "subschemaSubentry" in o, "No subschemaSubentry. TODO"
         subSchemas = o["subschemaSubentry"]
         assert len(subSchemas) == 1, "More than one subschemaSubentry is not support yet. TODO"
         for s in subSchemas:
             return s
     else:
         raise ldaperrors.LDAPOther("DN matched multiple entries")
Пример #2
0
    def handleSearchResults(l):
        if len(l) == 0:
            raise ldaperrors.LDAPOther("No such DN")
        elif len(l) == 1:
            o = l[0]

            attributeTypes = []
            objectClasses = []
            for text in o.get("attributeTypes", []):
                attributeTypes.append(schema.AttributeTypeDescription(str(text)))
            for text in o.get("objectClasses", []):
                objectClasses.append(schema.ObjectClassDescription(str(text)))
            assert attributeTypes, "LDAP server doesn't give attributeTypes for subschemaSubentry dn=%s" % o.dn
            return (attributeTypes, objectClasses)
        else:
            raise ldaperrors.LDAPOther("DN matched multiple entries")
Пример #3
0
def request_success(resp, callback, *callback_args):
    def do(data):
        code = data['code']
        if code != 0:
            raise ldaperrors.reverse[code](data['msg'])
        return callback(data, resp, *callback_args)

    if resp.code != 200:
        raise ldaperrors.LDAPOther('Http server return ' + str(resp.code))

    d = resp.json()
    d.addCallback(do)
    return d
Пример #4
0
 def _failConnection(self, reason):
     self.transport.loseConnection()
     raise ldaperrors.LDAPOther(
         "Cannot connect to server.{}".format(reason))