Ejemplo n.º 1
0
def add_member(inst, basedn, log, args):
    cn = _get_arg(args.cn, msg="Enter %s of group to add member too" % RDN)
    dn = _get_arg(args.dn, msg="Enter dn to add as member")
    groups = MANY(inst, basedn)
    group = groups.get(cn)
    group.add_member(dn)
    log.info('added member: %s' % dn)
Ejemplo n.º 2
0
def remove_member(inst, basedn, log, args):
    cn = _get_arg(args.cn, msg="Enter %s of group to remove member from" % RDN)
    dn = _get_arg(args.dn, msg="Enter dn to remove as member")
    groups = MANY(inst, basedn)
    group = groups.get(cn)
    group.remove_member(dn)
    log.info('removed member: %s' % dn)
Ejemplo n.º 3
0
def reset_password(inst, basedn, log, args):
    dn = _get_arg(args.dn, msg="Enter dn to reset password")
    new_password = _get_arg(args.new_password, hidden=True, confirm=True,
        msg="Enter new password for %s" % dn)
    accounts = Accounts(inst, basedn)
    acct = accounts.get(dn=dn)
    acct.reset_password(new_password)
    log.info('reset password for %s' % dn)
Ejemplo n.º 4
0
def change_password(inst, basedn, log, args):
    dn = _get_arg(args.dn, msg="Enter dn to change password")
    cur_password = _get_arg(args.current_password, hidden=True, confirm=False,
        msg="Enter current password for %s" % dn)
    new_password = _get_arg(args.new_password, hidden=True, confirm=True,
        msg="Enter new password for %s" % dn)
    accounts = Accounts(inst, basedn)
    acct = accounts.get(dn=dn)
    acct.change_password(cur_password, new_password)
    log.info('changed password for %s' % dn)
Ejemplo n.º 5
0
def status(inst, basedn, log, args):
    dn = _get_arg( args.dn, msg="Enter dn to check")
    accounts = Accounts(inst, basedn)
    acct = accounts.get(dn=dn)
    acct_str = "locked: %s" % acct.is_locked()
    log.info('dn: %s' % dn)
    log.info(acct_str)
Ejemplo n.º 6
0
def query_matchingrule(inst, basedn, log, args):
    # Need the query type
    attr = _get_arg(args.attr, msg="Enter attribute to query")
    if args.json:
        print(inst.schema.query_matchingrule(attr, json=True))
    else:
        print("Not done")
Ejemplo n.º 7
0
def query_objectclass(inst, basedn, log, args):
    # Need the query type
    oc = _get_arg(args.attr, msg="Enter objectclass to query")
    if args.json:
        print(inst.schema.query_objectclass(oc, json=True))
    else:
        print("Not done")
Ejemplo n.º 8
0
def password_change(inst, basedn, log, args):
    # Due to an issue, we can't use extended op, so we have to
    # submit the password directly to the field.

    password = _get_arg(args.password, msg="Enter new directory manager password", hidden=True, confirm=True)
    dm = DirectoryManager(inst)
    dm.change_password(password)
Ejemplo n.º 9
0
def plugin_enable(inst, basedn, log, args):
    dn = _get_arg( args.dn, msg="Enter plugin dn to enable")
    mc = MANY(inst, basedn)
    o = mc.get(dn=dn)
    o.enable()
    o_str = o.display()
    log.info('Enabled %s', o_str)
Ejemplo n.º 10
0
def plugin_enable(inst, basedn, log, args):
    dn = _get_arg(args.dn, msg="Enter plugin dn to enable")
    mc = MANY(inst, basedn)
    o = mc.get(dn=dn)
    o.enable()
    o_str = o.display()
    log.info('Enabled %s', o_str)
def status(inst, basedn, log, args):
    uid = _get_arg(args.uid, msg="Enter %s to check" % RDN)
    uas = MANY(inst, basedn)
    acct = uas.get(uid)
    acct_str = "locked: %s" % acct.is_locked()
    log.info('uid: %s' % uid)
    log.info(acct_str)
Ejemplo n.º 12
0
def plugin_disable(inst, basedn, log, args, warn=True):
    dn = _get_arg( args.dn, msg="Enter plugin dn to disable")
    if warn:
        _warn(dn, msg="Disabling %s %s" % (SINGULAR.__name__, dn))
    mc = MANY(inst, basedn)
    o = mc.get(dn=dn)
    o.disable()
    o_str = o.display()
    log.info('Disabled %s', o_str)
Ejemplo n.º 13
0
def plugin_disable(inst, basedn, log, args, warn=True):
    dn = _get_arg(args.dn, msg="Enter plugin dn to disable")
    if warn:
        _warn(dn, msg="Disabling %s %s" % (SINGULAR.__name__, dn))
    mc = MANY(inst, basedn)
    o = mc.get(dn=dn)
    o.disable()
    o_str = o.display()
    log.info('Disabled %s', o_str)
Ejemplo n.º 14
0
def query_matchingrule(inst, basedn, log, args):
    log = log.getChild('query_matchingrule')
    schema = Schema(inst)
    # Need the query type
    attr = _get_arg(args.name, msg="Enter attribute to query")
    result = schema.query_matchingrule(attr, json=args.json)
    if args.json:
        print(dump_json(result, indent=4))
    else:
        print(result)
Ejemplo n.º 15
0
def query_objectclass(inst, basedn, log, args):
    log = log.getChild('query_objectclass')
    schema = Schema(inst)
    # Need the query type
    oc = _get_arg(args.name, msg="Enter objectclass to query")
    result = schema.query_objectclass(oc, json=args.json)
    if args.json:
        print(dump_json(result, indent=4))
    else:
        print(result)
Ejemplo n.º 16
0
def members(inst, basedn, log, args):
    cn = _get_arg(args.cn, msg="Enter %s of group" % RDN)
    groups = MANY(inst, basedn)
    group = groups.get(cn)
    # Display members?
    member_list = group.list_members()
    if len(member_list) == 0:
        log.info('No members to display')
    else:
        for m in member_list:
            log.info('dn: %s' % m)
def query_attributetype(inst, basedn, log, args):
    # Need the query type
    attr = _get_arg(args.attr, msg="Enter attribute to query")
    attributetype, must, may = inst.schema.query_attributetype(attr)
    print(attributetype)
    print("")
    print("MUST")
    for oc in must:
        print(oc)
    print("")
    print("MAY")
    for oc in may:
        print(oc)
Ejemplo n.º 18
0
def query_attributetype(inst, basedn, log, args):
    log = log.getChild('query_attributetype')
    schema = Schema(inst)
    # Need the query type
    attr = _get_arg(args.name, msg="Enter attribute to query")
    if args.json:
        print(dump_json(schema.query_attributetype(attr, json=args.json), indent=4))
    else:
        attributetype, must, may = schema.query_attributetype(attr, json=args.json)
        print(attributetype)
        print("")
        print("MUST")
        for oc in must:
            print(oc)
        print("")
        print("MAY")
        for oc in may:
            print(oc)
Ejemplo n.º 19
0
def backend_get(inst, basedn, log, args):
    rdn = _get_arg(args.selector, msg="Enter %s to retrieve" % RDN)
    _generic_get(inst, basedn, log.getChild('backend_get'), MANY, rdn, args)
Ejemplo n.º 20
0
def plugin_edit(inst, basedn, log, args):
    log = log.getChild('plugin_edit')
    rdn = _get_arg(args.selector, msg="Enter %s to retrieve" % RDN)
    plugins = Plugins(inst)
    plugin = plugins.get(rdn)
    generic_object_edit(plugin, log, args, arg_to_attr)
def unlock(inst, basedn, log, args):
    uid = _get_arg(args.uid, msg="Enter %s to check" % RDN)
    accounts = MANY(inst, basedn)
    acct = accounts.get(uid)
    acct.unlock()
    log.info('unlocked %s' % uid)
Ejemplo n.º 22
0
def plugin_get(inst, basedn, log, args):
    rdn = _get_arg( args.selector, msg="Enter %s to retrieve" % RDN)
    _generic_get(inst, basedn, log.getChild('plugin_get'), MANY, rdn)
Ejemplo n.º 23
0
def plugin_get_dn(inst, basedn, log, args):
    dn = _get_arg( args.dn, msg="Enter dn to retrieve")
    _generic_get_dn(inst, basedn, log.getChild('plugin_get_dn'), MANY, dn)
Ejemplo n.º 24
0
def unlock(inst, basedn, log, args):
    dn = _get_arg( args.dn, msg="Enter dn to check")
    accounts = Accounts(inst, basedn)
    acct = accounts.get(dn=dn)
    acct.unlock()
    log.info('unlocked %s' % dn)
Ejemplo n.º 25
0
def modify(inst, basedn, log, args, warn=True):
    dn = _get_arg( args.dn, msg="Enter dn to modify")
    _generic_modify_dn(inst, basedn, log.getChild('_generic_modify'), MANY, dn, args)
Ejemplo n.º 26
0
def remove_attributetype(inst, basedn, log, args):
    log = log.getChild('remove_attributetype')
    attr = _get_arg(args.name, msg="Enter attribute to remove")
    schema = Schema(inst)
    schema.remove_attributetype(attr)
    print("Successfully removed the attributetype")
Ejemplo n.º 27
0
def delete(inst, basedn, log, args):
    dn = _get_arg(args, msg="Enter dn to delete")
    _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn))
    _generic_delete(inst, basedn, log.getChild('_generic_delete'), SINGULAR,
                    dn)
Ejemplo n.º 28
0
def get_dn(inst, basedn, log, args):
    dn = lambda args: _get_arg(args.dn, msg="Enter dn to retrieve")
    _generic_get_dn(inst, basedn, log.getChild('_generic_get_dn'), MANY, dn)
Ejemplo n.º 29
0
def get_link(inst, basedn, log, args, warn=True):
    rdn = _get_arg(args.CHAIN_NAME[0], msg="Enter 'cn' to retrieve")
    _generic_get(inst, basedn, log.getChild('get_link'), ChainingLinks, rdn,
                 args)
Ejemplo n.º 30
0
def remove_objectclass(inst, basedn, log, args):
    log = log.getChild('remove_objectclass')
    attr = _get_arg(args.name, msg="Enter objectClass to remove")
    schema = Schema(inst)
    schema.remove_objectclass(attr)
    print("Successfully removed the objectClass")
Ejemplo n.º 31
0
def backend_get_dn(inst, basedn, log, args):
    dn = _get_arg(args.dn, msg="Enter dn to retrieve")
    _generic_get_dn(inst, basedn, log.getChild('backend_get_dn'), MANY, dn,
                    args)
Ejemplo n.º 32
0
def backend_delete(inst, basedn, log, args, warn=True):
    dn = _get_arg(args.dn, msg="Enter dn to delete")
    if warn:
        _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn))
    _generic_delete(inst, basedn, log.getChild('backend_delete'), SINGULAR, dn,
                    args)
Ejemplo n.º 33
0
def backend_delete(inst, basedn, log, args, warn=True):
    dn = _get_arg( args.dn, msg="Enter dn to delete")
    if warn:
        _warn(dn, msg="Deleting %s %s" % (SINGULAR.__name__, dn))
    _generic_delete(inst, basedn, log.getChild('backend_delete'), SINGULAR, dn)