Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if e.errno == errno.ENOENT:
pass
else:
raise
else:
seen = set()
for fn in filenames:
base, ext = os.path.splitext(fn)
if ext not in ['.dir', '.ldif']:
continue
if base in seen:
continue
seen.add(base)
dn = distinguishedname.DistinguishedName(
listOfRDNs=((distinguishedname.RelativeDistinguishedName(base),)
+ self.dn.split()))
e = self.__class__(os.path.join(self.path, base + '.dir'), dn)
children.append(e)
return children
def handle_LDAPModifyDNRequest(self, request, controls, reply):
self.checkControls(controls)
dn = distinguishedname.DistinguishedName(request.entry)
newrdn = distinguishedname.RelativeDistinguishedName(request.newrdn)
deleteoldrdn = bool(request.deleteoldrdn)
if not deleteoldrdn:
raise ldaperrors.LDAPUnwillingToPerform(
"Cannot handle preserving old RDN yet.")
newSuperior = request.newSuperior
if newSuperior is None:
newSuperior = dn.up()
else:
newSuperior = distinguishedname.DistinguishedName(newSuperior)
newdn = distinguishedname.DistinguishedName(
listOfRDNs=(newrdn,)+newSuperior.split())
root = interfaces.IConnectedLDAPEntry(self.factory)
d = root.lookup(dn)
def _gotEntry(entry):
d = entry.move(newdn)
def _deleteChild(self, rdn):
if not isinstance(rdn, distinguishedname.RelativeDistinguishedName):
rdn = distinguishedname.RelativeDistinguishedName(stringValue=rdn)
for c in self._sync_children():
if c.dn.split()[0] == rdn:
return c.delete()
raise ldaperrors.LDAPNoSuchObject(rdn)
def _cbSetPassword(self, ctx, newPassword, serviceName):
e = getEntry(ctx, self.dn)
rdn = distinguishedname.RelativeDistinguishedName(
attributeTypesAndValues=[
distinguishedname.LDAPAttributeTypeAndValue(
attributeType='cn', value=serviceName),
distinguishedname.LDAPAttributeTypeAndValue(
attributeType='owner', value=str(self.dn))
])
d = e.addChild(rdn, {
'objectClass': ['serviceSecurityObject'],
'cn': [serviceName],
'owner': [str(self.dn)],
'userPassword': ['{crypt}!'],
})
def _setPass(e, newPassword):
d = e.setPassword(newPassword)
return d
d.addCallback(_setPass, newPassword)
def _deleteChild(self, rdn):
if not isinstance(rdn, distinguishedname.RelativeDistinguishedName):
rdn = distinguishedname.RelativeDistinguishedName(stringValue=rdn)
rdn_str = rdn.toWire()
try:
return self._children.pop(rdn_str)
except KeyError:
raise ldaperrors.LDAPNoSuchObject(rdn)