Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 35 reserved for undefined isLeaf
class LDAPAliasDereferencingProblem(LDAPException):
resultCode = 36
name = b'aliasDereferencingProblem'
# 37-47 unused
class LDAPInappropriateAuthentication(LDAPException):
resultCode = 48
name = b'inappropriateAuthentication'
class LDAPInvalidCredentials(LDAPException):
resultCode = 49
name = b'invalidCredentials'
class LDAPInsufficientAccessRights(LDAPException):
resultCode = 50
name = b'insufficientAccessRights'
class LDAPBusy(LDAPException):
resultCode = 51
name = b'busy'
class LDAPUnavailable(LDAPException):
resultCode = 52
class LDAPUnknownError(LDAPException):
def __init__(self, resultCode, message=None):
assert resultCode not in LDAPExceptionCollection.collection, \
"resultCode %r must be unknown" % resultCode
self.code = resultCode
LDAPException.__init__(self, message)
def toWire(self):
codeName = b'unknownError(%d)' % self.code
if self.message:
return b'%s: %s' % (codeName, to_bytes(self.message))
else:
return codeName
class LDAPOperationsError(LDAPException):
resultCode = 1
name = b'operationsError'
class LDAPProtocolError(LDAPException):
resultCode = 2
name = b'protocolError'
class LDAPTimeLimitExceeded(LDAPException):
resultCode = 3
name = b'timeLimitExceeded'
class LDAPSizeLimitExceeded(LDAPException):
resultCode = 4
name = b'unavailable'
class LDAPUnwillingToPerform(LDAPException):
resultCode = 53
name = b'unwillingToPerform'
class LDAPLoopDetect(LDAPException):
resultCode = 54
name = b'loopDetect'
# 55-63 unused
class LDAPNamingViolation(LDAPException):
resultCode = 64
name = b'namingViolation'
class LDAPObjectClassViolation(LDAPException):
resultCode = 65
name = b'objectClassViolation'
class LDAPNotAllowedOnNonLeaf(LDAPException):
resultCode = 66
name = b'notAllowedOnNonLeaf'
class LDAPNotAllowedOnRDN(LDAPException):
resultCode = 67
class LDAPConfidentialityRequired(LDAPException):
resultCode = 13
name = b'confidentialityRequired'
class LDAPSaslBindInProgress(LDAPException):
resultCode = 14
name = b'saslBindInProgress'
class LDAPNoSuchAttribute(LDAPException):
resultCode = 16
name = b'noSuchAttribute'
class LDAPUndefinedAttributeType(LDAPException):
resultCode = 17
name = b'undefinedAttributeType'
class LDAPInappropriateMatching(LDAPException):
resultCode = 18
name = b'inappropriateMatching'
class LDAPConstraintViolation(LDAPException):
resultCode = 19
name = b'constraintViolation'
class LDAPAttributeOrValueExists(LDAPException):
resultCode = 20
class LDAPNamingViolation(LDAPException):
resultCode = 64
name = b'namingViolation'
class LDAPObjectClassViolation(LDAPException):
resultCode = 65
name = b'objectClassViolation'
class LDAPNotAllowedOnNonLeaf(LDAPException):
resultCode = 66
name = b'notAllowedOnNonLeaf'
class LDAPNotAllowedOnRDN(LDAPException):
resultCode = 67
name = b'notAllowedOnRDN'
class LDAPEntryAlreadyExists(LDAPException):
resultCode = 68
name = b'entryAlreadyExists'
class LDAPObjectClassModsProhibited(LDAPException):
resultCode = 69
name = b'objectClassModsProhibited'
# 70 reserved for CLDAP
class LDAPInsufficientAccessRights(LDAPException):
resultCode = 50
name = b'insufficientAccessRights'
class LDAPBusy(LDAPException):
resultCode = 51
name = b'busy'
class LDAPUnavailable(LDAPException):
resultCode = 52
name = b'unavailable'
class LDAPUnwillingToPerform(LDAPException):
resultCode = 53
name = b'unwillingToPerform'
class LDAPLoopDetect(LDAPException):
resultCode = 54
name = b'loopDetect'
# 55-63 unused
class LDAPNamingViolation(LDAPException):
resultCode = 64
name = b'namingViolation'
class LDAPObjectClassViolation(LDAPException):
resultCode = 65
name = b'objectClassViolation'
class LDAPNotAllowedOnNonLeaf(LDAPException):
resultCode = 66
name = b'notAllowedOnNonLeaf'
class LDAPNotAllowedOnRDN(LDAPException):
resultCode = 67
name = b'notAllowedOnRDN'
class LDAPEntryAlreadyExists(LDAPException):
resultCode = 68
name = b'entryAlreadyExists'
class LDAPObjectClassModsProhibited(LDAPException):
resultCode = 69
name = b'objectClassModsProhibited'
# 70 reserved for CLDAP
class LDAPAffectsMultipleDSAs(LDAPException):
resultCode = 71
name = b'affectsMultipleDSAs'
# 72-79 unused
name = b'loopDetect'
# 55-63 unused
class LDAPNamingViolation(LDAPException):
resultCode = 64
name = b'namingViolation'
class LDAPObjectClassViolation(LDAPException):
resultCode = 65
name = b'objectClassViolation'
class LDAPNotAllowedOnNonLeaf(LDAPException):
resultCode = 66
name = b'notAllowedOnNonLeaf'
class LDAPNotAllowedOnRDN(LDAPException):
resultCode = 67
name = b'notAllowedOnRDN'
class LDAPEntryAlreadyExists(LDAPException):
resultCode = 68
name = b'entryAlreadyExists'
class LDAPObjectClassModsProhibited(LDAPException):
resultCode = 69
class LDAPInvalidDNSyntax(LDAPException):
resultCode = 34
name = b'invalidDNSyntax'
# 35 reserved for undefined isLeaf
class LDAPAliasDereferencingProblem(LDAPException):
resultCode = 36
name = b'aliasDereferencingProblem'
# 37-47 unused
class LDAPInappropriateAuthentication(LDAPException):
resultCode = 48
name = b'inappropriateAuthentication'
class LDAPInvalidCredentials(LDAPException):
resultCode = 49
name = b'invalidCredentials'
class LDAPInsufficientAccessRights(LDAPException):
resultCode = 50
name = b'insufficientAccessRights'
class LDAPBusy(LDAPException):
resultCode = 51
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""LDAP protocol server"""
from ldaptor import interfaces, delta
from ldaptor.protocols import pureldap, pureber
from ldaptor.protocols.ldap import distinguishedname, ldaperrors
from twisted.python import log
from twisted.internet import protocol, defer
class LDAPServerConnectionLostException(ldaperrors.LDAPException):
pass
class BaseLDAPServer(protocol.Protocol):
debug = False
def __init__(self):
self.buffer = b''
self.connected = None
berdecoder = pureldap.LDAPBERDecoderContext_TopLevel(
inherit=pureldap.LDAPBERDecoderContext_LDAPMessage(
fallback=pureldap.LDAPBERDecoderContext(
fallback=pureber.BERDecoderContext()),
inherit=pureldap.LDAPBERDecoderContext(
fallback=pureber.BERDecoderContext())))