How to use the ldaptor.protocols.ldap.ldapconnector.LDAPClientCreator function in ldaptor

To help you get started, we’ve selected a few ldaptor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github twisted / ldaptor / docs / source / examples / ldap_parallelsearch.py View on Github external
def main(base, serviceLocationOverrides, numOfConnections=3, numOfSearches=3):
    log.startLogging(sys.stderr, setStdout=0)
    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)
github twisted / ldaptor / ldaptor / apps / webui / search.py View on Github external
def child_base(self, context):
        cfg = context.locate(interfaces.ILDAPConfig)

        c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
        d=c.connectAnonymously(iwebui.ICurrentDN(context),
                               cfg.getServiceLocationOverrides())

        def _search(proto, base):
            baseEntry = ldapsyntax.LDAPEntry(client=proto,
                                             dn=base)
            d=baseEntry.search(scope=pureldap.LDAP_SCOPE_baseObject,
                               sizeLimit=1)
            def _cb(result, proto):
                proto.unbind()
                return result
            d.addBoth(_cb, proto)
            return d
        d.addCallback(_search, iwebui.ICurrentDN(context))

        def _first(results, dn):
github twisted / ldaptor / docs / source / examples / addressbook / 04_dynamic / addressbook.py View on Github external
def _search(self, searchFilter):
        c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
        d=c.connectAnonymously(self.config.getBaseDN(),
                               self.config.getServiceLocationOverrides())

        def _doSearch(proto, searchFilter):
            searchFilter = ldapfilter.parseFilter(searchFilter)
            baseEntry = ldapsyntax.LDAPEntry(client=proto,
                                             dn=self.config.getBaseDN())
            d=baseEntry.search(filterObject=searchFilter)
            return d

        d.addCallback(_doSearch, searchFilter)
        return d
github twisted / ldaptor / docs / source / examples / addressbook / 05_form / addressbook.py View on Github external
def child(self, context, name):
        if name == 'searchFilter':
            return self.search
        if name != 'results':
            return None
        config = context.locate(ILDAPConfig)

        c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
        d=c.connectAnonymously(config.getBaseDN(),
                               config.getServiceLocationOverrides())

        def _search(proto, base, searchFilter):
            baseEntry = ldapsyntax.LDAPEntry(client=proto, dn=base)
            d=baseEntry.search(filterObject=searchFilter)
            return d

        d.addCallback(_search, config.getBaseDN(), self.search)
        return d
github twisted / ldaptor / docs / source / examples / addressbook / 03_webapp / addressbook.py View on Github external
def _search(self):
        c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
        d=c.connectAnonymously(self.config.getBaseDN(),
                               self.config.getServiceLocationOverrides())

        def _doSearch(proto):
            searchFilter = ldapfilter.parseFilter('(gn=j*)')
            baseEntry = ldapsyntax.LDAPEntry(client=proto,
                                             dn=self.config.getBaseDN())
            d=baseEntry.search(filterObject=searchFilter)
            return d

        d.addCallback(_doSearch)
        return d
github twisted / ldaptor / docs / source / examples / addressbook / 02_script / addressbook.py View on Github external
def search(config):
    c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
    d=c.connectAnonymously(config['base'],
                           config['serviceLocationOverrides'])

    def _doSearch(proto, config):
        searchFilter = ldapfilter.parseFilter('(gn=j*)')
        baseEntry = ldapsyntax.LDAPEntry(client=proto, dn=config['base'])
        d=baseEntry.search(filterObject=searchFilter)
        return d

    d.addCallback(_doSearch, config)
    return d
github twisted / ldaptor / ldaptor / protocols / ldap / merger.py View on Github external
def connectionMade(self):
        clientCreator = ldapconnector.LDAPClientCreator(
            reactor, self.protocol)
        for (c, tls) in zip(self.configs, self.use_tls):
            d = clientCreator.connect(dn='',
                                      overrides=c.getServiceLocationOverrides())
            if tls:
                d.addCallback(lambda x: x.startTLS())
            d.addCallback(self._cbConnectionMade)
            d.addErrback(self._failConnection)

        ldapserver.BaseLDAPServer.connectionMade(self)
github twisted / ldaptor / ldaptor / apps / webui / search.py View on Github external
def child_results(self, context):
        assert self.filter is not None
        cfg = context.locate(interfaces.ILDAPConfig)

        c=ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
        curDN = iwebui.ICurrentDN(context)
        d=c.connectAnonymously(curDN,
                               cfg.getServiceLocationOverrides())

        def _search(proto, dn, searchFilter, scope):
            baseEntry = ldapsyntax.LDAPEntry(client=proto, dn=dn)
            d=baseEntry.search(filterObject=searchFilter,
                               scope=scope,
                               sizeLimit=20,
                               sizeLimitIsNonFatal=True)
            def _cb(result, proto):
                proto.unbind()
                return result
            d.addBoth(_cb, proto)
            return d
        d.addCallback(_search, curDN, self.filter, self.data['scope'])
github twisted / ldaptor / ldaptor / protocols / ldap / proxy.py View on Github external
def connectionMade(self):
        clientCreator = ldapconnector.LDAPClientCreator(
            reactor, self.protocol)
        d = clientCreator.connect(
            dn='',
            overrides=self.config.getServiceLocationOverrides())
        d.addCallback(self._cbConnectionMade)
        d.addErrback(self._failConnection)

        ldapserver.BaseLDAPServer.connectionMade(self)