How to use the ldaptor.protocols.ldap.ldapsyntax 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 / tests / test_ldapsyntax.py View on Github external
def TODOtestDNKeyExistenceFailure(self):
	self.failUnlessRaises(ldapsyntax.DNNotPresentError,
			      ldapsyntax.LDAPObject,
			      client=DummyLDAPClient(),
			      dn='cn=foo,dc=example,dc=com',
			      attributes={
	    'foo': ['bar'],
	    })
github twisted / ldaptor / ldaptor / apps / webui / edit.py View on Github external
newRDN.remove(rdn)

                    # Try to find a replacement RDN. Possibilities are
                    # new values from the edit form and old values
                    # currently in LDAP.
                    possible = list(new)
                    possible.extend(self.entry.get(rdn.attributeType, []))
                    for o in old:
                        # Values to be removed are not acceptable as
                        # new RDN.
                        try:
                            possible.remove(o)
                        except ValueError:
                            pass
                    if not possible:
                        raise ldapsyntax.CannotRemoveRDNError \
                              (rdn.attributeType,
                               rdn.value)
                    newRDN.append(distinguishedname.LDAPAttributeTypeAndValue(attributeType=attr,
                                                                              value=possible[0]))
                    old.remove(rdn.value)
                    try:
                        new.remove(possible[0])
                    except ValueError:
                        pass
        if newRDN is not None:
            newRDN = distinguishedname.RelativeDistinguishedName(newRDN)
            changes_desc[tags.li[
                _("changing %s: changing RDN to say %s") \
                %(repr(attr), newRDN)]]
            newDN = distinguishedname.DistinguishedName(
                (newRDN,)+self.entry.dn.split()[1:]
github twisted / ldaptor / ldaptor / apps / webui / change_password.py View on Github external
def getEntry(ctx, dn):
    user = ctx.locate(inevow.ISession).getLoggedInRoot().loggedIn
    e=ldapsyntax.LDAPEntry(client=user.client, dn=dn)
    return e
github twisted / ldaptor / ldaptor / apps / webui / search.py View on Github external
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))
github twisted / ldaptor / ldaptor / apps / webui / delete.py View on Github external
def data_entry(self, context, data):
        user = context.locate(inevow.ISession).getLoggedInRoot().loggedIn
        assert user

        entry = ldapsyntax.LDAPEntry(client=user.client, dn=self.dn)
        d = entry.fetch()
        d.addErrback(ErrorWrapper)
        return d
github twisted / ldaptor / docs / source / examples / addressbook / 04_dynamic / addressbook.py View on Github external
def _doSearch(proto, searchFilter):
            searchFilter = ldapfilter.parseFilter(searchFilter)
            baseEntry = ldapsyntax.LDAPEntry(client=proto,
                                             dn=self.config.getBaseDN())
            d=baseEntry.search(filterObject=searchFilter)
            return d
github twisted / ldaptor / ldaptor / protocols / ldap / svcbindproxy.py View on Github external
def _startSearch(self, request, controls, reply):
        services = list(self.services)
        baseDN = self.config.getIdentityBaseDN()
        e = ldapsyntax.LDAPEntryWithClient(client=self.client,
                                           dn=baseDN)
        d = self._tryService(services, e, request, controls, reply)
        d.addCallback(self._maybeFallback, request, controls, reply)
        return d
github twisted / ldaptor / ldaptor / entryhelpers.py View on Github external
return not self.match(filter.value)
        elif isinstance(filter, pureldap.LDAPFilter_extensibleMatch):
            if filter.matchingRule is None:
                attrib = filter.type.value
                match_value = filter.matchValue.value
                match_value_lower = safelower(match_value)
                if (match_value_lower in [val.lower() for val in self.get(attrib, [])]):
                    return True
                for rdn in self.dn.listOfRDNs:
                    for av in rdn.attributeTypesAndValues:
                        if attrib is None or attrib == av.attributeType:
                            if match_value_lower == safelower(av.value):
                                return True
                return False
            else:
                raise ldapsyntax.MatchNotImplemented(filter)
        else:
            raise ldapsyntax.MatchNotImplemented(filter)
github twisted / ldaptor / ldaptor / apps / webui / move.py View on Github external
def childFactory(self, context, name):
        dn = uriUnquote(name)
        session = inevow.ISession(context)
        userEntry = session.getLoggedInRoot().loggedIn

        move = session.getComponent(IMove)
        if move is None:
            move = []
            session.setComponent(IMove, move)

        e = ldapsyntax.LDAPEntryWithClient(dn=dn,
                                           client=userEntry.client)
        move.append(e)
        u = url.URL.fromContext(context).sibling('search')
        return u
github twisted / ldaptor / docs / source / examples / addressbook / 02_script / addressbook.py View on Github external
def _doSearch(proto, config):
        searchFilter = ldapfilter.parseFilter('(gn=j*)')
        baseEntry = ldapsyntax.LDAPEntry(client=proto, dn=config['base'])
        d=baseEntry.search(filterObject=searchFilter)
        return d