How to use the ldaptor.protocols.pureldap.LDAPAttributeDescription 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
d.addBoth(lambda x, r=reactor: r.callLater(0, r.crash))
	reactor.run()
	self.assertEquals(len(l), 1)
	# now the search is done

	self.failUnlessEqual(
	    client.sent,
	    str(pureldap.LDAPSearchRequest(
	    baseObject='dc=example,dc=com',
	    scope=pureldap.LDAP_SCOPE_wholeSubtree,
	    derefAliases=pureldap.LDAP_DEREF_neverDerefAliases,
	    sizeLimit=0,
	    timeLimit=0,
	    typesOnly=0,
	    filter=pureldap.LDAPFilter_equalityMatch(
		attributeDesc=pureldap.LDAPAttributeDescription(value='foo'),
		assertionValue=pureldap.LDAPAssertionValue(value='a')),
	    attributes=['foo', 'bar'])))
	self.failUnlessEqual(len(l), 1)
	self.failUnlessEqual(len(l[0]), 2)

	self.failUnlessEqual(l[0][0],
			     ldapsyntax.LDAPObject(
	    client=client,
	    dn='cn=foo,dc=example,dc=com',
	    attributes={
	    'foo': ['a'],
	    'bar': ['b', 'c'],
	    }))

	self.failUnlessEqual(l[0][1],
			     ldapsyntax.LDAPObject(
github twisted / ldaptor / ldaptor / protocols / pureldap.py View on Github external
class LDAPMatchingRuleId(LDAPString):
    pass


class LDAPAssertionValue(BEROctetString):
    pass


class LDAPMatchingRuleAssertion_matchingRule(LDAPMatchingRuleId):
    tag = CLASS_CONTEXT | 0x01
    pass


class LDAPMatchingRuleAssertion_type(LDAPAttributeDescription):
    tag = CLASS_CONTEXT | 0x02
    pass


class LDAPMatchingRuleAssertion_matchValue(LDAPAssertionValue):
    tag = CLASS_CONTEXT | 0x03
    pass


class LDAPMatchingRuleAssertion_dnAttributes(BERBoolean):
    tag = CLASS_CONTEXT | 0x04
    pass


class LDAPBERDecoderContext_MatchingRuleAssertion(BERDecoderContext):
    Identities = {
github twisted / ldaptor / ldaptor / protocols / ldap / svcbindproxy.py View on Github external
pureldap.LDAPFilter_equalityMatch(attributeDesc=pureldap.LDAPAttributeDescription('cn'),
                                              assertionValue=pureldap.LDAPAssertionValue(serviceName)),

            pureldap.LDAPFilter_or([
            # no time
            pureldap.LDAPFilter_not(pureldap.LDAPFilter_present('validFrom')),
            # or already valid
            pureldap.LDAPFilter_lessOrEqual(attributeDesc=pureldap.LDAPAttributeDescription('validFrom'),
                                            assertionValue=pureldap.LDAPAssertionValue(timestamp)),
            ]),

            pureldap.LDAPFilter_or([
            # no time
            pureldap.LDAPFilter_not(pureldap.LDAPFilter_present('validUntil')),
            # or still valid
            pureldap.LDAPFilter_greaterOrEqual(attributeDesc=pureldap.LDAPAttributeDescription('validUntil'),
                                               assertionValue=pureldap.LDAPAssertionValue(timestamp)),
            ]),

            ]),
                             attributes=('1.1',))

        def _gotEntries(entries):
            if not entries:
                return None
            assert len(entries)==1 #TODO
            e = entries[0]
            d = e.bind(request.auth)
            return d
        d.addCallback(_gotEntries)
        d.addCallbacks(
            callback=self._loopIfNone,
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 / ldaptor / numberalloc.py View on Github external
def guess(self, num):
        d=self.ldapObject.search(
            filterObject=pureldap.LDAPFilter_equalityMatch(
            attributeDesc=pureldap.LDAPAttributeDescription(value=self.numberType),
            assertionValue=pureldap.LDAPAssertionValue(value=str(num))),
            sizeLimit=1)
        d.addCallback(lambda results: len(results))
        return d
github twisted / ldaptor / ldaptor / protocols / ldap / svcbindproxy.py View on Github external
def _tryService(self, services, baseEntry, request, controls, reply):
        try:
            serviceName = services.pop(0)
        except IndexError:
            return None
        timestamp = self.timestamp()
        d = baseEntry.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(request.dn)),
            pureldap.LDAPFilter_equalityMatch(attributeDesc=pureldap.LDAPAttributeDescription('cn'),
                                              assertionValue=pureldap.LDAPAssertionValue(serviceName)),

            pureldap.LDAPFilter_or([
            # no time
            pureldap.LDAPFilter_not(pureldap.LDAPFilter_present('validFrom')),
            # or already valid
            pureldap.LDAPFilter_lessOrEqual(attributeDesc=pureldap.LDAPAttributeDescription('validFrom'),
                                            assertionValue=pureldap.LDAPAssertionValue(timestamp)),
            ]),

            pureldap.LDAPFilter_or([
            # no time
            pureldap.LDAPFilter_not(pureldap.LDAPFilter_present('validUntil')),
            # or still valid
            pureldap.LDAPFilter_greaterOrEqual(attributeDesc=pureldap.LDAPAttributeDescription('validUntil'),
                                               assertionValue=pureldap.LDAPAssertionValue(timestamp)),
github twisted / ldaptor / ldaptor / ldapfilter.py View on Github external
return (lambda attr:
            pureldap.LDAPFilter_equalityMatch(
                attributeDesc=pureldap.LDAPAttributeDescription(attr),
                assertionValue=pureldap.LDAPAssertionValue(t[0])))