Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
l=[]
for connection in xrange(0, numOfConnections):
c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
d=c.connectAnonymously(base, serviceLocationOverrides)
d.addCallback(_search, base, connection, numOfSearches)
d.addErrback(error)
l.append(d)
dl=defer.DeferredList(l)
dl.addBoth(lambda dummy: reactor.stop())
reactor.run()
sys.exit(exitStatus)
if __name__ == "__main__":
base='dc=example,dc=com'
main(base=distinguishedname.DistinguishedName(base),
serviceLocationOverrides={base: ('localhost', None)},
numOfConnections=5,
numOfSearches=10)
def __init__(self,
baseDN,
serviceLocationOverrides=None):
self.baseDN = distinguishedname.DistinguishedName(baseDN)
self.serviceLocationOverrides = {}
if serviceLocationOverrides is not None:
for k,v in serviceLocationOverrides.items():
dn = distinguishedname.DistinguishedName(k)
self.serviceLocationOverrides[dn]=v
def __init__(self, reactor, dn, factory,
overrides=None, bindAddress=None):
if not isinstance(dn, distinguishedname.DistinguishedName):
dn = distinguishedname.DistinguishedName(stringValue=dn)
if overrides is None:
overrides = {}
self.override = self._findOverRide(dn, overrides)
domain = dn.getDomainName() or ''
SRVConnector.__init__(self, reactor,
'ldap', domain, factory,
connectFuncKwArgs={'bindAddress': bindAddress})
def locateChild(self, ctx, segments):
ret = super(LdaptorWebUIGadget, self).locateChild(ctx, segments)
if ret != rend.NotFound:
return ret
path = segments[0]
unquoted=uriUnquote(path)
try:
dn = distinguishedname.DistinguishedName(stringValue=unquoted)
except distinguishedname.InvalidRelativeDistinguishedName, e:
# TODO There's no way to throw a FormException at this stage.
u = url.URL.fromContext(ctx)
# TODO protect against guard bug, see
# http://divmod.org/users/roundup.twistd/nevow/issue74
u = u.child('')
# TODO freeform_post!configurableName!methodName
u.add('basedn', path)
return u, []
r=LdaptorWebUIGadget2(baseObject=dn)
ctx.remember(self.config, interfaces.ILDAPConfig)
ctx.remember(dn, iwebui.ICurrentDN)
return r, segments[1:]
def handle_LDAPSearchRequest(self, request, controls, reply):
self.checkControls(controls)
if (request.baseObject == b''
and request.scope == pureldap.LDAP_SCOPE_baseObject
and request.filter == pureldap.LDAPFilter_present('objectClass')):
return self.getRootDSE(request, reply)
dn = distinguishedname.DistinguishedName(request.baseObject)
root = interfaces.IConnectedLDAPEntry(self.factory)
d = root.lookup(dn)
d.addCallback(self._cbSearchGotBase, dn, request, reply)
d.addErrback(self._cbSearchLDAPError)
d.addErrback(defer.logError)
d.addErrback(self._cbSearchOtherError)
return d
def __init__(self,
baseDN=None,
serviceLocationOverrides=None,
identityBaseDN=None,
identitySearch=None):
if baseDN is not None:
baseDN = distinguishedname.DistinguishedName(baseDN)
self.baseDN = baseDN
self.serviceLocationOverrides = {}
if serviceLocationOverrides is not None:
for k,v in serviceLocationOverrides.items():
dn = distinguishedname.DistinguishedName(k)
self.serviceLocationOverrides[dn]=v
if identityBaseDN is not None:
identityBaseDN = distinguishedname.DistinguishedName(identityBaseDN)
self.identityBaseDN = identityBaseDN
if identitySearch is not None:
self.identitySearch = identitySearch
def main():
import sys
from twisted.python import log
log.startLogging(sys.stderr, setStdout=0)
config = {
'base':
distinguishedname.DistinguishedName('ou=People,dc=example,dc=com'),
'serviceLocationOverrides': {
distinguishedname.DistinguishedName('dc=example,dc=com'):
('localhost', 10389),
}
}
d = search(config)
def _show(results):
for item in results:
print item
d.addCallback(_show)
d.addErrback(defer.logError)
d.addBoth(lambda _: reactor.stop())
reactor.run()