forked from twisted/ldaptor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-ldapserver.tac
35 lines (26 loc) · 1016 Bytes
/
test-ldapserver.tac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- python -*-
import shutil
from twisted.application import service, internet
from twisted.internet import protocol
from twisted.python import components
from twisted.trial import util
from ldaptor import ldiftree, interfaces
from ldaptor.protocols.ldap import ldapserver
DBPATH = 'ldaptor/test/ldif/webtests'
TMPDBPATH = '%s.tmp' % DBPATH
shutil.rmtree(TMPDBPATH, ignore_errors=True)
shutil.copytree(DBPATH, TMPDBPATH)
db = ldiftree.LDIFTreeEntry(TMPDBPATH)
class LDAPServerFactory(protocol.ServerFactory):
protocol = ldapserver.LDAPServer
def __init__(self, root):
self.root = root
ldapserver.LDAPServer.debug = True
components.registerAdapter(lambda x: x.root,
LDAPServerFactory,
interfaces.IConnectedLDAPEntry)
application = service.Application("ldaptor-server")
myService = service.IServiceCollection(application)
factory = LDAPServerFactory(db)
myServer = internet.TCPServer(38942, factory)
myServer.setServiceParent(myService)