Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
jemrobinson committed Feb 29, 2024
1 parent 626674e commit 767429a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apricot/ldap/read_only_ldap_server.py
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
LDAPSearchResultEntry,
)
from twisted.internet import defer
from twisted.python import log


class ReadOnlyLDAPServer(LDAPServer):
@@ -21,6 +22,7 @@ def getRootDSE( # noqa: N802
"""
Handle an LDAP Root RSE request
"""
log.msg(f"Calling getRootDSE with {request}")
return super().getRootDSE(request, reply)

def handle_LDAPAddRequest( # noqa: N802
@@ -32,6 +34,7 @@ def handle_LDAPAddRequest( # noqa: N802
"""
Refuse to handle an LDAP add request
"""
log.msg(f"Calling LDAP add with {request}")
id((request, controls, reply)) # ignore unused arguments
msg = "ReadOnlyLDAPServer will not handle LDAP add requests"
raise LDAPProtocolError(msg)
@@ -45,6 +48,7 @@ def handle_LDAPBindRequest( # noqa: N802
"""
Handle an LDAP bind request
"""
log.msg(f"Calling LDAP bind with '{request}' '{controls}' (DN='{request.dn}')")
return super().handle_LDAPBindRequest(request, controls, reply)

def handle_LDAPCompareRequest( # noqa: N802
@@ -56,6 +60,7 @@ def handle_LDAPCompareRequest( # noqa: N802
"""
Handle an LDAP compare request
"""
log.msg(f"Calling LDAP compare with '{request}' '{controls}'")
return super().handle_LDAPCompareRequest(request, controls, reply)

def handle_LDAPDelRequest( # noqa: N802
@@ -67,6 +72,7 @@ def handle_LDAPDelRequest( # noqa: N802
"""
Refuse to handle an LDAP delete request
"""
log.msg(f"Calling LDAP del with '{request}' '{controls}'")
id((request, controls, reply)) # ignore unused arguments
msg = "ReadOnlyLDAPServer will not handle LDAP delete requests"
raise LDAPProtocolError(msg)
@@ -80,6 +86,7 @@ def handle_LDAPExtendedRequest( # noqa: N802
"""
Handle an LDAP extended request
"""
log.msg(f"Calling LDAP extended with '{request}' '{controls}'")
return super().handle_LDAPExtendedRequest(request, controls, reply)

def handle_LDAPModifyDNRequest( # noqa: N802
@@ -91,6 +98,7 @@ def handle_LDAPModifyDNRequest( # noqa: N802
"""
Refuse to handle an LDAP modify DN request
"""
log.msg(f"Calling LDAP modify DN with '{request}' '{controls}'")
id((request, controls, reply)) # ignore unused arguments
msg = "ReadOnlyLDAPServer will not handle LDAP modify DN requests"
raise LDAPProtocolError(msg)
@@ -104,6 +112,7 @@ def handle_LDAPModifyRequest( # noqa: N802
"""
Refuse to handle an LDAP modify request
"""
log.msg(f"Calling LDAP modify with '{request}' '{controls}'")
id((request, controls, reply)) # ignore unused arguments
msg = "ReadOnlyLDAPServer will not handle LDAP modify requests"
raise LDAPProtocolError(msg)
@@ -117,6 +126,7 @@ def handle_LDAPUnbindRequest( # noqa: N802
"""
Handle an LDAP unbind request
"""
log.msg(f"Calling LDAP unbind with '{request}' '{controls}'")
super().handle_LDAPUnbindRequest(request, controls, reply)

def handle_LDAPSearchRequest( # noqa: N802
@@ -128,4 +138,5 @@ def handle_LDAPSearchRequest( # noqa: N802
"""
Handle an LDAP search request
"""
log.msg(f"Calling LDAP search with '{request}' '{controls}'")
return super().handle_LDAPSearchRequest(request, controls, reply)

0 comments on commit 767429a

Please sign in to comment.