コード例 #1
0
ファイル: add.py プロジェクト: tubaman/ldaptor
    def _process2(self, changes, context, rdn, kw):
        cfg = context.locate(interfaces.ILDAPConfig)
        user = context.locate(inevow.ISession).getLoggedInRoot().loggedIn

        if not changes:
            return _("No changes!") #TODO

        changes_desc=""
        mod={}
        for attr,new in changes:
            if new:
                if attr not in mod:
                    mod[attr]=[]
                mod[attr].extend(new)
                changes_desc=changes_desc+"<br>adding %s: %s"%(repr(attr), ', '.join(map(repr, new)))

        if not mod:
            return _("No changes (2)!") #TODO

        e = ldapsyntax.LDAPEntryWithClient(client=user.client,
                                           dn=iwebui.ICurrentDN(context))
        d = e.addChild(rdn, mod)
        #d.addCallback(lambda e: "Added %s successfully." % e.dn)
        d.addErrback(lambda reason: _("Failed: %s.") % reason.getErrorMessage())
        return d
コード例 #2
0
ファイル: edit.py プロジェクト: KenMacD/ldaptor
    def render_status(self, context, data):
        try:
            obj = context.locate(inevow.IHand)
        except KeyError:
            return context.tag.clear()

        if not isinstance(obj, EditStatus):
            return context.tag.clear()[obj]

        u=url.URL.fromContext(context)
        u=u.parentdir().parentdir().clear()

        return context.tag.clear()[
            _("Edited "),
            tags.a(href=u.parentdir()
                   .child(obj.entry.dn)
                   .child("search"))[obj.entry.dn],
            _(" successfully. "),

            # TODO share implementation with entryLinks
            '[',
            tags.a(href=u.sibling('move').child(uriQuote(obj.entry.dn)))[_('move')],
            '|',
            tags.a(href=u.sibling('delete').child(uriQuote(obj.entry.dn)))[_('delete')],
            '|',
            tags.a(href=u.sibling('change_password').child(uriQuote(obj.entry.dn)))[_('change password')],
            ']',

            tags.p[obj.changes],

            ]
コード例 #3
0
ファイル: delete.py プロジェクト: KenMacD/ldaptor
 def data_header(self, ctx, data):
     u=url.URL.fromContext(ctx).up().clear()
     l=[]
     l.append(tags.a(href=u.sibling("search"))[_("Search")])
     l.append(tags.a(href=u.sibling("add"))[_("add new entry")])
     l.append(tags.a(href=u.sibling("edit").child(str(self.dn)))[_("edit")])
     return l
コード例 #4
0
ファイル: edit.py プロジェクト: KenMacD/ldaptor
 def bind_edit(self, ctx):
     formFields=self._getFormFields()
     return annotate.MethodBinding(
         'edit',
         annotate.Method(arguments=formFields,
                         label=_('Edit')),
         action=_('Edit'))
コード例 #5
0
 def data_header(self, ctx, data):
     u = url.URL.fromContext(ctx).up().clear()
     l = []
     l.append(tags.a(href=u.sibling("search"))[_("Search")])
     l.append(tags.a(href=u.sibling("add"))[_("add new entry")])
     l.append(tags.a(href=u.sibling("edit").child(str(self.dn)))[_("edit")])
     return l
コード例 #6
0
ファイル: edit.py プロジェクト: KenMacD/ldaptor
 def data_header(self, ctx, data):
     u=url.URL.fromContext(ctx)
     u=u.parentdir().parentdir().clear()
     l=[]
     l.append(tags.a(href=u.sibling("search"))[_("Search")])
     l.append(tags.a(href=u.sibling("add"))[_("add new entry")])
     return l
コード例 #7
0
    def _process2(self, changes, context, rdn, kw):
        cfg = context.locate(interfaces.ILDAPConfig)
        user = context.locate(inevow.ISession).getLoggedInRoot().loggedIn

        if not changes:
            return _("No changes!")  #TODO

        changes_desc = ""
        mod = {}
        for attr, new in changes:
            if new:
                if attr not in mod:
                    mod[attr] = []
                mod[attr].extend(new)
                changes_desc = changes_desc + "<br>adding %s: %s" % (
                    repr(attr), ', '.join(map(repr, new)))

        if not mod:
            return _("No changes (2)!")  #TODO

        e = ldapsyntax.LDAPEntryWithClient(client=user.client,
                                           dn=iwebui.ICurrentDN(context))
        d = e.addChild(rdn, mod)
        #d.addCallback(lambda e: "Added %s successfully." % e.dn)
        d.addErrback(
            lambda reason: _("Failed: %s.") % reason.getErrorMessage())
        return d
コード例 #8
0
 def data_header(self, ctx, data):
     u = url.URL.fromContext(ctx)
     u = u.parentdir().parentdir().clear()
     l = []
     l.append(tags.a(href=u.sibling("search"))[_("Search")])
     l.append(tags.a(href=u.sibling("add"))[_("add new entry")])
     return l
コード例 #9
0
ファイル: search.py プロジェクト: norox/ldaptor
    def bind_search(self, ctx):
        l = []
        l.append(annotate.Argument("ctx", annotate.Context()))
        for field in config.getSearchFieldNames():
            l.append(annotate.Argument("search_%s" % field, annotate.String(label=field)))
        l.append(annotate.Argument("searchfilter", annotate.String(label=_("Advanced search"))))
        l.append(
            annotate.Argument(
                "scope",
                annotate.Choice(
                    label=_("Search depth"),
                    choices=[
                        pureldap.LDAP_SCOPE_wholeSubtree,
                        pureldap.LDAP_SCOPE_singleLevel,
                        pureldap.LDAP_SCOPE_baseObject,
                    ],
                    stringify=strScope,
                    default=pureldap.LDAP_SCOPE_wholeSubtree,
                ),
            )
        )

        return annotate.MethodBinding(
            name="search", action=_("Search"), typeValue=annotate.Method(arguments=l, label=_("Search"))
        )
コード例 #10
0
ファイル: delete.py プロジェクト: KenMacD/ldaptor
 def bind_delete(self, ctx):
     return annotate.MethodBinding(
         'delete',
         annotate.Method(arguments=[
         annotate.Argument('ctx', annotate.Context()),
         ],
                         label=_('Confirm delete')),
         action=_('Delete'))
コード例 #11
0
ファイル: change_password.py プロジェクト: Jbran77/ldaptor
 def bind_remove(self, ctx):
     return annotate.MethodBinding('remove',
                                   annotate.Method(arguments=[
                                       annotate.Argument(
                                           'ctx', annotate.Context()),
                                   ],
                                                   label=_('Remove')),
                                   action=_('Remove'))
コード例 #12
0
ファイル: change_password.py プロジェクト: Jbran77/ldaptor
 def bind_generateRandom(self, ctx):
     return annotate.MethodBinding(
         'generateRandom',
         annotate.Method(arguments=[
             annotate.Argument('ctx', annotate.Context()),
         ],
                         label=_('Generate random')),
         action=_('Generate random'))
コード例 #13
0
 def bind_delete(self, ctx):
     return annotate.MethodBinding(
         'delete',
         annotate.Method(arguments=[
             annotate.Argument('ctx', annotate.Context()),
         ],
                         label=_('Confirm delete')),
         action=_('Delete'))
コード例 #14
0
ファイル: search.py プロジェクト: Jbran77/ldaptor
 def bind_cancel(self, ctx):
     return annotate.MethodBinding(
         'cancel',
         annotate.Method(arguments=[
         annotate.Argument('context', annotate.Context()),
         ],
                         label=_('Cancel')),
         action=_('Cancel'))
コード例 #15
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def bind_generateRandom(self, ctx):
     return annotate.MethodBinding(
         'generateRandom',
         annotate.Method(arguments=[
         annotate.Argument('ctx', annotate.Context()),
         ],
                         label=_('Generate random')),
         action=_('Generate random'))
コード例 #16
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def bind_remove(self, ctx):
     return annotate.MethodBinding(
         'remove',
         annotate.Method(arguments=[
         annotate.Argument('ctx', annotate.Context()),
         ],
                         label=_('Remove')),
         action=_('Remove'))
コード例 #17
0
ファイル: search.py プロジェクト: Jbran77/ldaptor
def strScope(scope):
    if scope == pureldap.LDAP_SCOPE_wholeSubtree:
        return _('whole subtree')
    elif scope == pureldap.LDAP_SCOPE_singleLevel:
        return _('single level')
    elif scope == pureldap.LDAP_SCOPE_baseObject:
        return _('baseobject')
    else:
        raise RuntimeError, 'scope is not known: %r' % scope
コード例 #18
0
ファイル: search.py プロジェクト: norox/ldaptor
def strScope(scope):
    if scope == pureldap.LDAP_SCOPE_wholeSubtree:
        return _("whole subtree")
    elif scope == pureldap.LDAP_SCOPE_singleLevel:
        return _("single level")
    elif scope == pureldap.LDAP_SCOPE_baseObject:
        return _("baseobject")
    else:
        raise RuntimeError, "scope is not known: %r" % scope
コード例 #19
0
ファイル: search.py プロジェクト: norox/ldaptor
 def render_entryLinks(self, ctx, data):
     u = url.URL.fromContext(ctx).parentdir().clear()
     l = [
         (u.sibling("edit").child(uriQuote(data)), _("edit")),
         (u.sibling("move").child(uriQuote(data)), _("move")),
         (u.sibling("delete").child(uriQuote(data)), _("delete")),
         (u.sibling("change_password").child(uriQuote(data)), _("change password")),
     ]
     return self.render_sequence(ctx, l)
コード例 #20
0
 def render_overview(self, ctx, data):
     if self.auxiliaryObjectClasses:
         return ctx.tag.clear()[_('Using objectclasses %s and %s.') % (
             self.structuralObjectClass.name[0],
             ', '.join([oc.name[0] for oc in self.auxiliaryObjectClasses]),
         )]
     else:
         return ctx.tag.clear()[_('Using objectclass %s.') %
                                (self.structuralObjectClass.name[0], )]
コード例 #21
0
ファイル: add.py プロジェクト: tubaman/ldaptor
 def bind_add(self, ctx):
     return annotate.MethodBinding(
         'add',
         annotate.Method(arguments=[
         annotate.Argument('context', annotate.Context()),
         annotate.Argument('smartObjectClass', annotate.Choice(choices=self.plugins)),
         ],
                         label=_('Add')),
         action=_('Add'))
コード例 #22
0
 def bind_add(self, ctx):
     return annotate.MethodBinding(
         'add',
         annotate.Method(arguments=[
             annotate.Argument('context', annotate.Context()),
             annotate.Argument('smartObjectClass',
                               annotate.Choice(choices=self.plugins)),
         ],
                         label=_('Add')),
         action=_('Add'))
コード例 #23
0
ファイル: search.py プロジェクト: Jbran77/ldaptor
 def render_entryLinks(self, ctx, data):
     u = url.URL.fromContext(ctx).parentdir().clear()
     l = [ (u.sibling('edit').child(uriQuote(data)),
            _('edit')),
           (u.sibling('move').child(uriQuote(data)),
            _('move')),
           (u.sibling('delete').child(uriQuote(data)),
            _('delete')),
           (u.sibling('change_password').child(uriQuote(data)),
            _('change password')),
           ]
     return self.render_sequence(ctx, l)
コード例 #24
0
ファイル: add.py プロジェクト: tubaman/ldaptor
 def render_overview(self, ctx, data):
     if self.auxiliaryObjectClasses:
         return ctx.tag.clear()[
             _('Using objectclasses %s and %s.') % (
             self.structuralObjectClass.name[0],
             ', '.join([oc.name[0] for oc in self.auxiliaryObjectClasses]),
             )]
     else:
         return ctx.tag.clear()[
             _('Using objectclass %s.') % (
             self.structuralObjectClass.name[0],
             )]
コード例 #25
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def bind_setServicePassword(self, ctx):
     return annotate.MethodBinding(
         'setServicePassword',
         annotate.Method(arguments=[
         annotate.Argument('ctx', annotate.Context()),
         annotate.Argument('newPassword', annotate.PasswordEntry(required=True,
                                                                 label=_('New password'))),
         annotate.Argument('again', annotate.PasswordEntry(required=True,
                                                           label=_('Again'))),
         ],
                         label=_('Set password')),
         action=_('Set password'))
コード例 #26
0
 def bind_go(self, ctx):
     return annotate.MethodBinding(
         'go',
         annotate.Method(arguments=[
             annotate.Argument('ctx', annotate.Context()),
             annotate.Argument(
                 'baseDN',
                 LDAPDN(label=_('Base DN'),
                        description=_(
                            "The top-level LDAP DN you want"
                            " to browse, e.g. dc=example,dc=com"))),
         ],
                         label=_('Go')),
         action=_('Go'))
コード例 #27
0
ファイル: change_password.py プロジェクト: Jbran77/ldaptor
 def bind_setServicePassword(self, ctx):
     return annotate.MethodBinding(
         'setServicePassword',
         annotate.Method(arguments=[
             annotate.Argument('ctx', annotate.Context()),
             annotate.Argument(
                 'newPassword',
                 annotate.PasswordEntry(required=True,
                                        label=_('New password'))),
             annotate.Argument(
                 'again',
                 annotate.PasswordEntry(required=True, label=_('Again'))),
         ],
                         label=_('Set password')),
         action=_('Set password'))
コード例 #28
0
ファイル: login.py プロジェクト: Jbran77/ldaptor
class LoginPage(rend.Page):
    """The resource that is returned when you are not logged in"""

    implements(iskin.ISkinnable)

    title = _('Login')

    docFactory = loaders.xmlfile(
        'login.xhtml',
        templateDir=os.path.split(os.path.abspath(__file__))[0])

    def __init__(self, history):
        self.history = history
        super(LoginPage, self).__init__()

    def locateChild(self, request, segments):
        return LoginPage(self.history + list(segments)), []

    def render_form(self, context, data):
        current = url.URL.fromContext(context)
        action = getActionURL(current, self.history)
        context.fillSlots('action-url', str(action))
        return context.tag

    render_i18n = i18n.render()
コード例 #29
0
ファイル: move.py プロジェクト: Jbran77/ldaptor
class MovePage(rend.Page):
    implements(iskin.ISkinnable)

    title = _('Ldaptor Move Page')

    addSlash = True
    docFactory = loaders.xmlfile('move.xhtml',
                                 templateDir=os.path.split(
                                     os.path.abspath(__file__))[0])

    def render_url(self, ctx, data):
        u = url.URL.fromContext(ctx)
        return ctx.tag(href=u.parentdir().child('search'))

    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

    render_i18n = i18n.render()
コード例 #30
0
    def generatePasswords(self, request, **kw):
        entries = []
        for k, v in kw.items():
            if not k.startswith('dn_'):
                continue
            k = k[len('dn_'):]
            if not v:
                continue
            assert k in self.ldapObjects
            entries.append(self.ldapObjects[k])

        if not entries:
            return _('No passwords to change.')
        d = generate_password.generate(reactor, len(entries))

        def _gotPasswords(passwords, entries):
            assert len(passwords) == len(entries)
            l = []
            for entry, pwd in zip(entries, passwords):
                d = entry.setPassword(newPasswd=pwd)

                def _cb(entry, pwd):
                    return (entry, pwd)

                d.addCallback(_cb, pwd)
                l.append(d)
            return defer.DeferredList(l, consumeErrors=True)

        d.addCallback(_gotPasswords, entries)
        d.addCallback(MassPasswordChangeStatus)
        return d
コード例 #31
0
class MassPasswordChangePage(rend.Page):
    implements(iskin.ISkinnable)

    title = _('Ldaptor Mass Password Change Page')

    addSlash = True
    docFactory = loaders.xmlfile('mass_change_password.xhtml',
                                 templateDir=os.path.split(
                                     os.path.abspath(__file__))[0])

    def __init__(self, baseObject):
        super(MassPasswordChangePage, self).__init__()
        self.baseObject = baseObject

    def render_url(self, context, data):
        u = url.URL.fromContext(context)
        return context.tag(href=u.parentdir().child('search'))

    def childFactory(self, context, name):
        entry = inevow.ISession(context).getLoggedInRoot().loggedIn

        filt = uriUnquote(name)

        e = ldapsyntax.LDAPEntry(client=entry.client, dn=self.baseObject)
        d = e.search(filterText=filt, sizeLimit=20)
        d.addCallback(ReallyMassPasswordChangePage)
        return d

    render_i18n = i18n.render()
コード例 #32
0
    def generatePasswords(self, request, **kw):
        entries = []
        for k,v in kw.items():
            if not k.startswith('dn_'):
                continue
            k = k[len('dn_'):]
            if not v:
                continue
            assert k in self.ldapObjects
            entries.append(self.ldapObjects[k])

        if not entries:
            return _('No passwords to change.')
        d=generate_password.generate(reactor, len(entries))

        def _gotPasswords(passwords, entries):
            assert len(passwords)==len(entries)
            l=[]
            for entry, pwd in zip(entries, passwords):
                d=entry.setPassword(newPasswd=pwd)
                def _cb(entry, pwd):
                    return (entry, pwd)
                d.addCallback(_cb, pwd)
                l.append(d)
            return defer.DeferredList(l,
                                      consumeErrors=True)
        d.addCallback(_gotPasswords, entries)
        d.addCallback(MassPasswordChangeStatus)
        return d
コード例 #33
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def setPassword(self, ctx, newPassword, again):
     d = defer.maybeDeferred(checkPasswordTypos, newPassword, again)
     d.addCallback(lambda dummy: self._setPassword(ctx, newPassword))
     d.addCallback(lambda dummy: _('Password set.'))
     def eb(fail):
         return _("Failed: %s") % fail.getErrorMessage()
     d.addErrback(eb)
     return d
コード例 #34
0
ファイル: gadget.py プロジェクト: norox/ldaptor
 def bind_go(self, ctx):
     return annotate.MethodBinding(
         "go",
         annotate.Method(
             arguments=[
                 annotate.Argument("ctx", annotate.Context()),
                 annotate.Argument(
                     "baseDN",
                     LDAPDN(
                         label=_("Base DN"),
                         description=_("The top-level LDAP DN you want" " to browse, e.g. dc=example,dc=com"),
                     ),
                 ),
             ],
             label=_("Go"),
         ),
         action=_("Go"),
     )
コード例 #35
0
ファイル: change_password.py プロジェクト: Jbran77/ldaptor
    def setPassword(self, ctx, newPassword, again):
        d = defer.maybeDeferred(checkPasswordTypos, newPassword, again)
        d.addCallback(lambda dummy: self._setPassword(ctx, newPassword))
        d.addCallback(lambda dummy: _('Password set.'))

        def eb(fail):
            return _("Failed: %s") % fail.getErrorMessage()

        d.addErrback(eb)
        return d
コード例 #36
0
 def cb(dummy):
     basedn = iwebui.ICurrentDN(ctx)
     while (basedn != '' and self.dn.contains(basedn)):
         basedn = basedn.up()
     u = url.URL.fromContext(ctx)
     u = u.parentdir().parentdir()
     if basedn != '':
         u = u.child(basedn).child('search')
     request.setComponent(iformless.IRedirectAfterPost, u)
     return _("Deleted %s.") % self.dn
コード例 #37
0
 def render_error_or_pass(self, context, data):
     if isinstance(data, ErrorWrapper):
         return context.tag.clear() \
                [ tags.strong(style="color: red;") \
                  [ _('An error occurred: '),
                    data.value.getErrorMessage(),
                    ]
                  ]
     else:
         return context.tag
コード例 #38
0
ファイル: delete.py プロジェクト: KenMacD/ldaptor
 def render_error_or_pass(self, context, data):
     if isinstance(data, ErrorWrapper):
         return context.tag.clear() \
                [ tags.strong(style="color: red;") \
                  [ _('An error occurred: '),
                    data.value.getErrorMessage(),
                    ]
                  ]
     else:
         return context.tag
コード例 #39
0
ファイル: delete.py プロジェクト: KenMacD/ldaptor
 def cb(dummy):
     basedn = iwebui.ICurrentDN(ctx)
     while (basedn != ''
            and self.dn.contains(basedn)):
         basedn = basedn.up()
     u=url.URL.fromContext(ctx)
     u=u.parentdir().parentdir()
     if basedn != '':
         u=u.child(basedn).child('search')
     request.setComponent(iformless.IRedirectAfterPost, u)
     return _("Deleted %s.") % self.dn
コード例 #40
0
class ReallyMassPasswordChangePage(rend.Page):
    implements(iskin.ISkinnable)

    title = _('Ldaptor Mass Password Change Page')

    addSlash = True
    docFactory = loaders.xmlfile('mass_change_password-really.xhtml',
                                 templateDir=os.path.split(
                                     os.path.abspath(__file__))[0])

    def __init__(self, entries):
        super(ReallyMassPasswordChangePage, self).__init__()
        self.entries = entries

    def data_header(self, ctx, data):
        u = url.URL.fromContext(ctx)
        u = u.parentdir().parentdir().clear()
        l = []
        l.append(tags.a(href=u.sibling("search"))[_("Search")])
        l.append(tags.a(href=u.sibling("add"))[_("add new entry")])
        return l

    def configurable_(self, context):
        request = context.locate(inevow.IRequest)
        return MassPasswordChangeForm(self.entries)

    def render_form(self, context, data):
        return webform.renderForms()[context.tag]

    def render_passthrough(self, context, data):
        return context.tag.clear()[data]

    def render_status(self, context, data):
        try:
            obj = context.locate(inevow.IHand)
        except KeyError:
            return context.tag.clear()

        if not isinstance(obj, MassPasswordChangeStatus):
            return context.tag.clear()[obj]

        dl = tags.dl(compact="compact")
        context.tag.clear()[dl]
        for success, x in obj.deferlist:
            if success:
                entry, pwd = x
                dl[tags.dt[entry.dn], tags.dd[pwd]]
            else:
                context.tag[_('Failed: '), x.getErrorMessage()]

        return context.tag

    render_i18n = i18n.render()
コード例 #41
0
ファイル: search.py プロジェクト: Jbran77/ldaptor
 def move(self, context):
     cfg = context.locate(interfaces.ILDAPConfig)
     newDN = distinguishedname.DistinguishedName(
         self.original.dn.split()[:1]
         + iwebui.ICurrentDN(context).split())
     origDN = self.original.dn
     d = self.original.move(newDN)
     d.addCallback(lambda dummy: _('Moved %s to %s.') % (origDN, newDN))
     def _cb(r, context):
         self._remove(context)
         return r
     d.addCallback(_cb, context)
     return d
コード例 #42
0
ファイル: search.py プロジェクト: norox/ldaptor
    def move(self, context):
        cfg = context.locate(interfaces.ILDAPConfig)
        newDN = distinguishedname.DistinguishedName(self.original.dn.split()[:1] + iwebui.ICurrentDN(context).split())
        origDN = self.original.dn
        d = self.original.move(newDN)
        d.addCallback(lambda dummy: _("Moved %s to %s.") % (origDN, newDN))

        def _cb(r, context):
            self._remove(context)
            return r

        d.addCallback(_cb, context)
        return d
コード例 #43
0
ファイル: search.py プロジェクト: Jbran77/ldaptor
    def bind_search(self, ctx):
        l = []
        l.append(annotate.Argument('ctx', annotate.Context()))
        for field in config.getSearchFieldNames():
            l.append(annotate.Argument('search_%s' % field,
                                       annotate.String(label=field)))
        l.append(annotate.Argument('searchfilter',
                                   annotate.String(label=_("Advanced search"))))
        l.append(annotate.Argument(
            'scope',
            annotate.Choice(label=_("Search depth"),
                            choices=[ pureldap.LDAP_SCOPE_wholeSubtree,
                                      pureldap.LDAP_SCOPE_singleLevel,
                                      pureldap.LDAP_SCOPE_baseObject,
                                      ],
                            stringify=strScope,
                            default=pureldap.LDAP_SCOPE_wholeSubtree)))

        return annotate.MethodBinding(
            name='search',
            action=_("Search"),
            typeValue=annotate.Method(arguments=l,
                                      label=_('Search')))
コード例 #44
0
class LdaptorWebUIGadget2(rend.Page):
    implements(iskin.ISkinnable)

    title = _('Ldaptor Web Interface')

    addSlash = True

    def __init__(self, baseObject):
        super(LdaptorWebUIGadget2, self).__init__()
        self.baseObject = baseObject

    def child_(self, context):
        return inevow.IRequest(context).URLPath().child('search')

    def child_search(self, context):
        return search.getSearchPage()

    def child_edit(self, context):
        if not inevow.ISession(context).getLoggedInRoot().loggedIn:
            return login.LoginPage([str(self.baseObject), 'edit'])
        return edit.EditPage()

    def child_move(self, context):
        if not inevow.ISession(context).getLoggedInRoot().loggedIn:
            return login.LoginPage([str(self.baseObject), 'move'])
        return move.MovePage()

    def child_add(self, context):
        if not inevow.ISession(context).getLoggedInRoot().loggedIn:
            return login.LoginPage([str(self.baseObject), 'add'])
        return add.getResource(baseObject=self.baseObject,
                               request=inevow.IRequest(context))

    def child_delete(self, context):
        if not inevow.ISession(context).getLoggedInRoot().loggedIn:
            return login.LoginPage([str(self.baseObject), 'delete'])
        return delete.getResource()

    def child_mass_change_password(self, context):
        if not inevow.ISession(context).getLoggedInRoot().loggedIn:
            return login.LoginPage(
                [str(self.baseObject), 'mass_change_password'])
        return mass_change_password.MassPasswordChangePage(
            baseObject=self.baseObject)

    def child_change_password(self, context):
        if not inevow.ISession(context).getLoggedInRoot().loggedIn:
            return login.LoginPage([str(self.baseObject), 'change_password'])
        return change_password.getResource()
コード例 #45
0
    def __init__(self, objectClasses):
        super(AddOCForm, self).__init__(None)
        structural = []
        auxiliary = []
        for oc in objectClasses:
            if oc.type == 'STRUCTURAL':
                structural.append(oc)
            elif oc.type == 'AUXILIARY':
                auxiliary.append(oc)
        structural.sort()
        auxiliary.sort()

        class KludgeNevowChoice(object):
            """
            A kludge that allows using Choice with both Nevow 0.3 and
            newer.
            """
            def __init__(self, oc):
                self.name = oc.name
                self.desc = oc.desc

            def __str__(self):
                """
                For Choice in Nevow 0.4 and newer. Nevow 0.3 will use
                integer indexes. Actual stringification for display
                purposes happens in strObjectClass.
                """
                return self.name[0]

        formFields = [
            annotate.Argument('ctx', annotate.Context()),
            annotate.Argument('request', annotate.Request()),
            annotate.Argument(
                'structuralObjectClass',
                annotate.Choice(
                    label=_('Object type to create'),
                    choices=[KludgeNevowChoice(x) for x in structural],
                    stringify=strObjectClass)),
        ]
        for oc in auxiliary:
            formFields.append(
                annotate.Argument(
                    'auxiliary_%s' % oc.name[0],
                    annotate.Boolean(label=oc.name[0],
                                     description=oc.desc or '')))
        self.formFields = formFields
コード例 #46
0
ファイル: add.py プロジェクト: tubaman/ldaptor
    def __init__(self, objectClasses):
        super(AddOCForm, self).__init__(None)
        structural = []
        auxiliary = []
        for oc in objectClasses:
            if oc.type == 'STRUCTURAL':
                structural.append(oc)
            elif oc.type == 'AUXILIARY':
                auxiliary.append(oc)
        structural.sort()
        auxiliary.sort()


        class KludgeNevowChoice(object):
            """
            A kludge that allows using Choice with both Nevow 0.3 and
            newer.
            """
            def __init__(self, oc):
                self.name = oc.name
                self.desc = oc.desc
            def __str__(self):
                """
                For Choice in Nevow 0.4 and newer. Nevow 0.3 will use
                integer indexes. Actual stringification for display
                purposes happens in strObjectClass.
                """
                return self.name[0]

        formFields = [
            annotate.Argument('ctx',
                              annotate.Context()),
            annotate.Argument('request',
                              annotate.Request()),
            annotate.Argument('structuralObjectClass',
                              annotate.Choice(label=_('Object type to create'),
                                              choices=[KludgeNevowChoice(x) for x in structural],
                                              stringify=strObjectClass)),
            ]
        for oc in auxiliary:
            formFields.append(annotate.Argument(
                'auxiliary_%s' % oc.name[0],
                annotate.Boolean(label=oc.name[0],
                                 description=oc.desc or '')))
        self.formFields = formFields
コード例 #47
0
    def render_status(self, context, data):
        try:
            obj = context.locate(inevow.IHand)
        except KeyError:
            return context.tag.clear()

        if not isinstance(obj, MassPasswordChangeStatus):
            return context.tag.clear()[obj]

        dl = tags.dl(compact="compact")
        context.tag.clear()[dl]
        for success, x in obj.deferlist:
            if success:
                entry, pwd = x
                dl[tags.dt[entry.dn], tags.dd[pwd]]
            else:
                context.tag[_('Failed: '), x.getErrorMessage()]

        return context.tag
コード例 #48
0
    def render_status(self, context, data):
        try:
            obj = context.locate(inevow.IHand)
        except KeyError:
            return context.tag.clear()

        if not isinstance(obj, MassPasswordChangeStatus):
            return context.tag.clear()[obj]

        dl = tags.dl(compact="compact")
        context.tag.clear()[dl]
        for success, x in obj.deferlist:
            if success:
                entry, pwd = x
                dl[tags.dt[entry.dn],
                   tags.dd[pwd]]
            else:
                context.tag[_('Failed: '), x.getErrorMessage()]

        return context.tag
コード例 #49
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def bind_add(self, ctx):
     return annotate.MethodBinding(
         'add',
         annotate.Method(arguments=[
         annotate.Argument('ctx', annotate.Context()),
         annotate.Argument('serviceName', annotate.String(required=True,
                                                          label=_('Service name'))),
         annotate.Argument('newPassword', annotate.PasswordEntry(required=False,
                                                                 label=_('New password'),
                                                                 description=_("Leave empty to generate random password."))),
         annotate.Argument('again', annotate.PasswordEntry(required=False,
                                                           label=_('Again'))),
         ],
                         label=_('Add')),
         action=_('Add'))
コード例 #50
0
class GetDN(rend.Page):
    implements(iskin.ISkinnable)

    title = _('Ldaptor Delete Page')

    addSlash = True

    docFactory = loaders.xmlfile('delete-nodn.xhtml',
                                 templateDir=os.path.split(
                                     os.path.abspath(__file__))[0])

    def render_url(self, context, data):
        u = url.URL.fromContext(context)
        return context.tag(href=u.parentdir().child('search'))

    def childFactory(self, context, name):
        unquoted = uriUnquote(name)
        try:
            dn = distinguishedname.DistinguishedName(stringValue=unquoted)
        except distinguishedname.InvalidRelativeDistinguishedName, e:
            # TODO There's no way to throw a FormException at this stage.
            return None
        r = ConfirmDelete(dn=dn)
        return r
コード例 #51
0
ファイル: add.py プロジェクト: tubaman/ldaptor
    def render_status(self, context, data):
        try:
            obj = context.locate(inevow.IHand)
        except KeyError:
            return context.tag.clear()

        e = interfaces.ILDAPEntry(obj, None)
        if e is not None:
            status = AddStatus(entry=e)
        else:
            status = IAddStatus(obj, None)
            if status is None:
                return context.tag.clear()[obj]

        e = status.entry
        u=url.URL.fromContext(context)
        u=u.parentdir().parentdir().parentdir().clear()

        msg = [
            _("Added "),
            tags.a(href=u.parentdir().child(e.dn).child("search"))[e.dn],
            ]

        if status.password is not None:
            msg.extend([_(' with password '), status.password])

        return context.tag.clear()[
            msg,
            ' ',

            # TODO share implementation with entryLinks
            '[',
            tags.a(href=u.sibling('edit').child(uriQuote(e.dn)))[_('edit')],
            '|',
            tags.a(href=u.sibling('move').child(uriQuote(e.dn)))[_('move')],
            '|',
            tags.a(href=u.sibling('delete').child(uriQuote(e.dn)))[_('delete')],
            '|',
            tags.a(href=u.sibling('change_password').child(uriQuote(e.dn)))[_('change password')],
            ']',
            ]
コード例 #52
0
ファイル: change_password.py プロジェクト: Jbran77/ldaptor
 def bind_add(self, ctx):
     return annotate.MethodBinding(
         'add',
         annotate.Method(arguments=[
             annotate.Argument('ctx', annotate.Context()),
             annotate.Argument(
                 'serviceName',
                 annotate.String(required=True, label=_('Service name'))),
             annotate.Argument(
                 'newPassword',
                 annotate.PasswordEntry(
                     required=False,
                     label=_('New password'),
                     description=_(
                         "Leave empty to generate random password."))),
             annotate.Argument(
                 'again',
                 annotate.PasswordEntry(required=False, label=_('Again'))),
         ],
                         label=_('Add')),
         action=_('Add'))
コード例 #53
0
    def render_status(self, context, data):
        try:
            obj = context.locate(inevow.IHand)
        except KeyError:
            return context.tag.clear()

        e = interfaces.ILDAPEntry(obj, None)
        if e is not None:
            status = AddStatus(entry=e)
        else:
            status = IAddStatus(obj, None)
            if status is None:
                return context.tag.clear()[obj]

        e = status.entry
        u = url.URL.fromContext(context)
        u = u.parentdir().parentdir().parentdir().clear()

        msg = [
            _("Added "),
            tags.a(href=u.parentdir().child(e.dn).child("search"))[e.dn],
        ]

        if status.password is not None:
            msg.extend([_(' with password '), status.password])

        return context.tag.clear(
        )[msg, ' ',

          # TODO share implementation with entryLinks
          '[',
          tags.a(href=u.sibling('edit').child(uriQuote(e.dn)))[_('edit')], '|',
          tags.a(href=u.sibling('move').child(uriQuote(e.dn)))[_('move')], '|',
          tags.a(href=u.sibling('delete').child(uriQuote(e.dn)))[_('delete')],
          '|',
          tags.a(href=u.sibling('change_password').child(uriQuote(e.dn))
                 )[_('change password')], ']', ]
コード例 #54
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def _report(name):
     return _('Removed service %r') % name
コード例 #55
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def _cb(e):
     for cn in e.get('cn', []):
         return cn
     raise RuntimeError, \
           _("Service password entry has no attribute cn: %r") % e
コード例 #56
0
 def bind_generate(self, ctx):
     return annotate.MethodBinding('generatePasswords',
                                   annotate.Method(
                                       arguments=self.formFields,
                                       label=_('Generate passwords')),
                                   action=_('Generate passwords'))
コード例 #57
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def eb(fail):
     return _("Failed: %s") % fail.getErrorMessage()
コード例 #58
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def _status(newPassword, ctx):
     d = self._setPassword(ctx, newPassword)
     d.addCallback(lambda dummy: _('Password set to %s') % newPassword)
     return d
コード例 #59
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
def checkPasswordTypos(newPassword, again):
    if newPassword != again:
        raise annotate.ValidateError(
            {},
            formErrorMessage=_('Passwords do not match.'))
コード例 #60
0
ファイル: change_password.py プロジェクト: KenMacD/ldaptor
 def _report(dummy, name):
     return _('Added service %r') % name