Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def TODOtestDNKeyExistenceFailure(self):
self.failUnlessRaises(ldapsyntax.DNNotPresentError,
ldapsyntax.LDAPObject,
client=DummyLDAPClient(),
dn='cn=foo,dc=example,dc=com',
attributes={
'foo': ['bar'],
})
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:]
def getEntry(ctx, dn):
user = ctx.locate(inevow.ISession).getLoggedInRoot().loggedIn
e=ldapsyntax.LDAPEntry(client=user.client, dn=dn)
return e
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 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
def _doSearch(proto, searchFilter):
searchFilter = ldapfilter.parseFilter(searchFilter)
baseEntry = ldapsyntax.LDAPEntry(client=proto,
dn=self.config.getBaseDN())
d=baseEntry.search(filterObject=searchFilter)
return d
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
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)
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
def _doSearch(proto, config):
searchFilter = ldapfilter.parseFilter('(gn=j*)')
baseEntry = ldapsyntax.LDAPEntry(client=proto, dn=config['base'])
d=baseEntry.search(filterObject=searchFilter)
return d