Exemple #1
0
            include_project_users = True
        elif opt == '-v':
            verbose = True
        else:
            print 'Error: %s not supported!' % opt
            usage()
            sys.exit(0)

    if args:
        print 'Error: Non-option arguments are not supported - missing quotes?'
        usage()
        sys.exit(1)

    uid = 'unknown'
    errors = []
    (configuration, hits) = search_users(search_filter, conf_path, db_path,
                                         verbose)
    if not hits:
        print "No matching users in user DB"
    else:
        # Reuse conf and hits as a sparse user DB for speed
        conf_path, db_path = configuration, dict(hits)
        print "2FA status:"
        for (uid, user_dict) in hits:
            if not include_project_users and \
                    uid.split('/')[-1].startswith('GDP='):
                continue
            if verbose:
                print "Checking %s" % uid
            (_, err) = user_twofactor_status(uid, conf_path, db_path, fields,
                                             verbose)
            errors += err
Exemple #2
0
            usage()
            sys.exit(0)
        elif opt == '-I':
            search_filter['distinguished_name'] = val
        elif opt == '-n':
            name_only = True
        elif opt == '-C':
            search_filter['country'] = val
        elif opt == '-E':
            search_filter['email'] = val
        elif opt == '-F':
            search_filter['full_name'] = val
        elif opt == '-O':
            search_filter['organization'] = val
        elif opt == '-S':
            search_filter['state'] = val
        elif opt == '-v':
            verbose = True
        else:
            print 'Error: %s not supported!' % opt
            usage()
            sys.exit(0)

    hits = search_users(search_filter, conf_path, db_path, verbose)
    print "Matching users:"
    for (uid, user_dict) in hits:
        if name_only:
            print '%s' % user_dict['full_name']
        else:
            print '%s : %s' % (uid, user_dict)
Exemple #3
0
    if not args:
        print 'Must provide one or more URIs to import from'
        usage()
        sys.exit(1)

    users = []
    for url in args:
        url_dump = dump_contents(url, key_path, cert_path)
        users += parse_contents(url_dump)
    #print "DEBUG: raw users to import: %s" % users

    new_users = []
    for user_dict in users:
        id_search = default_search()
        id_search['distinguished_name'] = user_dict['distinguished_name']
        (configuration, hits) = search_users(id_search, conf_path, db_path,
                                             verbose)
        if hits:
            if verbose:
                print 'Not adding existing user: %(distinguished_name)s' % \
                      user_dict
            continue
        new_users.append(user_dict)
    #print "DEBUG: new users to import: %s" % new_users

    configuration = get_configuration_object()
    for user_dict in new_users:
        fill_user(user_dict)
        client_id = user_dict['distinguished_name']
        user_dict['comment'] = 'imported from external URI'
        if password == keyword_auto:
            print 'Auto generating password for user: %s' % client_id
Exemple #4
0
    if not args:
        print 'Must provide one or more URLs to import from'
        usage()
        sys.exit(1)

    users = []
    for url in args:
        url_dump = dump_contents(url, key_path, cert_path)
        users += parse_contents(url_dump)

    new_users = []
    for user_dict in users:
        id_search = default_search()
        id_search['distinguished_name'] = user_dict['distinguished_name']
        if search_users(id_search, conf_path, db_path, verbose):
            if verbose:
                print 'Not adding existing user: %s'\
                      % user_dict['distinguished_name']
            continue
        new_users.append(user_dict)

    for user_dict in new_users:
        fill_user(user_dict)
        user_id = user_dict['distinguished_name']
        user_dict['comment'] = 'imported from external URL'
        try:
            create_user(user_dict, conf_path, db_path, force, verbose)
        except Exception, exc:
            print exc
            continue