How to use the ldaptor.protocols.ldap.distinguishedname.RelativeDistinguishedName 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 / ldaptor / ldiftree.py View on Github external
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
github twisted / ldaptor / ldaptor / protocols / ldap / ldapserver.py View on Github external
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)
github twisted / ldaptor / ldaptor / ldiftree.py View on Github external
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)
github twisted / ldaptor / ldaptor / apps / webui / change_password.py View on Github external
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)
github twisted / ldaptor / ldaptor / inmemory.py View on Github external
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)