Example #1
0
   -d DB_PATH          Use DB_PATH as user data base file path
   -g                  Include GDP project users (usually same as owner)
   -h                  Show this help
   -I CERT_DN          Check only for user with ID (distinguished name)
   -v                  Verbose output
""" % {'name': name}


if '__main__' == __name__:
    (args, app_dir, db_path) = init_user_adm()
    conf_path = None
    fields = keyword_auto
    include_project_users = False
    verbose = False
    user_file = None
    search_filter = default_search()
    opt_args = 'c:d:ghf:I:v'
    try:
        (opts, args) = getopt.getopt(args, opt_args)
    except getopt.GetoptError, err:
        print 'Error: ', err.msg
        usage()
        sys.exit(1)

    for (opt, val) in opts:
        if opt == '-c':
            conf_path = val
        elif opt == '-d':
            db_path = val
        elif opt == '-f':
            fields = val.split()
Example #2
0
   -n                  Show only name
   -O ORGANIZATION     Search for organization
   -S STATE            Search for state
   -v                  Verbose output

Each search value can be a string or a pattern with * and ? as wildcards.
""" % {'name': name}


if '__main__' == __name__:
    (args, app_dir, db_path) = init_user_adm()
    conf_path = None
    verbose = False
    user_dict = {}
    opt_args = 'c:C:d:E:F:hI:nO:S:v'
    search_filter = default_search()
    name_only = False
    try:
        (opts, args) = getopt.getopt(args, opt_args)
    except getopt.GetoptError, err:
        print 'Error: ', err.msg
        usage()
        sys.exit(1)

    for (opt, val) in opts:
        if opt == '-c':
            conf_path = val
        elif opt == '-d':
            db_path = val
        elif opt == '-h':
            usage()
Example #3
0
            sys.exit(1)

    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']
Example #4
0
            print 'Error: %s not supported!' % opt
            sys.exit(1)

    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: