def get_reactor():
"""
:returns: the twisted reactor and the port number for the LDAP server
:rtype: tuple
"""
from twisted.internet import reactor
# We initialize our tree
tree = Tree()
# When the LDAP Server protocol wants to manipulate the DIT, it invokes
# `root = interfaces.IConnectedLDAPEntry(self.factory)` to get the root
# of the DIT. The factory that creates the protocol must therefore
# be adapted to the IConnectedLDAPEntry interface.
registerAdapter(
lambda x: x.root,
LDAPServerFactory,
IConnectedLDAPEntry)
factory = LDAPServerFactory(tree.db)
factory.debug = False
listener = reactor.listenTCP(0, factory)
port = listener.getHost().port
return reactor, port
ldap_server.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录