How to use the ldaptor.protocols.ldap.ldapsyntax.LDAPEntry 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 / client_paged_search_results.py View on Github external
def process_entry(client, args, search_filter, page_size=100, cookie=''):
    basedn = args.base_dn
    control_value = pureber.BERSequence([
        pureber.BERInteger(page_size),
        pureber.BEROctetString(cookie),
    ])
    controls = [('1.2.840.113556.1.4.319', None, control_value)]
    o = LDAPEntry(client, basedn)
    results, resp_controls  = yield o.search(
        filterText=search_filter,
        attributes=['dn'],
        controls=controls,
        return_controls=True)
    cookie = get_paged_search_cookie(resp_controls)
    defer.returnValue((results, cookie))
github twisted / ldaptor / docs / source / examples / addressbook / 03_webapp / addressbook.py View on Github external
def _doSearch(proto):
            searchFilter = ldapfilter.parseFilter('(gn=j*)')
            baseEntry = ldapsyntax.LDAPEntry(client=proto,
                                             dn=self.config.getBaseDN())
            d=baseEntry.search(filterObject=searchFilter)
            return d
github twisted / ldaptor / ldaptor / apps / webui / change_password.py View on Github external
def data_servicePasswords(self, ctx, data):
        user = ctx.locate(inevow.ISession).getLoggedInRoot().loggedIn
        config = interfaces.ILDAPConfig(ctx)
        e=ldapsyntax.LDAPEntry(client=user.client, dn=config.getBaseDN())
        d = e.search(filterObject=pureldap.LDAPFilter_and([
            pureldap.LDAPFilter_equalityMatch(attributeDesc=pureldap.LDAPAttributeDescription('objectClass'),
                                              assertionValue=pureldap.LDAPAssertionValue('serviceSecurityObject')),
            pureldap.LDAPFilter_equalityMatch(attributeDesc=pureldap.LDAPAttributeDescription('owner'),
                                              assertionValue=pureldap.LDAPAssertionValue(str(self.dn))),
            pureldap.LDAPFilter_present('cn'),
            ]),
                     attributes=['cn'])

        return d
github twisted / ldaptor / docs / source / examples / quickstart_client.py View on Github external
def onConnect(client):
    # The following arguments may be also specified as unicode strings
    # but it is recommended to use byte strings for ldaptor objects
    basedn = b'dc=example,dc=org'
    binddn = b'cn=bob,ou=people,dc=example,dc=org'
    bindpw = b'secret'
    query = b'(cn=bob)'
    try:
        yield client.bind(binddn, bindpw)
    except Exception as ex:
        print(ex)
        raise
    o = LDAPEntry(client, basedn)
    results = yield o.search(filterText=query)
    for entry in results:
        print(entry.getLDIF())
github twisted / ldaptor / ldaptor / apps / webui / add.py View on Github external
def _nonUserEditableAttributeType_getFreeNumber(self, attributeType, context):
        cfg = context.locate(interfaces.ILDAPConfig)
        entry = context.locate(inevow.ISession).getLoggedInRoot().loggedIn
        client = entry.client
        o=ldapsyntax.LDAPEntry(client=client,
                               dn=cfg.getBaseDN())
        d=numberalloc.getFreeNumber(ldapObject=o,
                                    numberType=attributeType,
                                    min=1000)
        d.addCallback(lambda x, a=attributeType: (a, [str(x)]))
        return d
github twisted / ldaptor / docs / source / examples / ldap_parallelsearch.py View on Github external
def _search(proto, base, connection, numOfSearches):
    l=[]
    baseEntry = ldapsyntax.LDAPEntry(client=proto,
                                     dn=base)
    for search in xrange(0, numOfSearches):
        d=baseEntry.search(callback=lambda x:
                           _handle_entry(x, connection, search))
        d.addErrback(error)
        l.append(d)

    dl=defer.DeferredList(l)
    return dl