Apache-Sling

 view release on metacpan or  search on metacpan

lib/Apache/Sling/LDAPSynch.pm  view on Meta::CPAN

sub config_hash {
    my ( $ldap_synch, $sling, @ARGV ) = @_;
    my $attributes;
    my $download_user_list;
    my $flag_disabled;
    my $ldap_attributes;
    my $ldap_base;
    my $ldap_dn;
    my $ldap_filter;
    my $ldap_host;
    my $ldap_pass;
    my $synch_full;
    my $synch_full_since;
    my $synch_listed;
    my $synch_listed_since;
    my $upload_user_list;

    my %ldap_synch_config = (
        'auth'               => \$sling->{'Auth'},
        'help'               => \$sling->{'Help'},
        'log'                => \$sling->{'Log'},
        'man'                => \$sling->{'Man'},
        'pass'               => \$sling->{'Pass'},
        'threads'            => \$sling->{'Threads'},
        'url'                => \$sling->{'URL'},
        'user'               => \$sling->{'User'},
        'verbose'            => \$sling->{'Verbose'},
        'attributes'         => $attributes,
        'download-user-list' => $download_user_list,
        'flag-disabled'      => $flag_disabled,
        'ldap-attributes'    => $ldap_attributes,
        'ldap-base'          => $ldap_base,
        'ldap-dn'            => $ldap_dn,
        'ldap-filter'        => $ldap_filter,
        'ldap-host'          => $ldap_host,
        'ldap-pass'          => $ldap_pass,
        'synch-full'         => $synch_full,
        'synch-full-since'   => $synch_full_since,
        'synch-listed'       => $synch_listed,
        'synch-listed-since' => $synch_listed_since,
        'upload-user-list'   => $upload_user_list
    );

    return \%ldap_synch_config;
}

#}}}

#{{{ sub help
sub help {

    print <<"EOF";
Usage: perl $0 [-OPTIONS [-MORE_OPTIONS]] [--] [PROGRAM_ARG1 ...]
The following options are accepted:

 --attributes or -a (attribs)          - Comma separated list of attributes.
 --auth (type)                         - Specify auth type. If ommitted, default is used.
 --download-user-list (userList)       - Download user list to file userList
 --flag-disabled or -f                 - property to denote user should be disabled.
 --help or -?                          - View the script synopsis and options.
 --ldap-attributes or -A (attribs)     - Specify ldap attributes to be updated.
 --ldap-base or -B (ldapBase)          - Specify ldap base to synchronize users from.
 --ldap-dn or -D (ldapDN)              - Specify ldap DN for authentication.
 --ldap-filter or -F (filter)          - Specify ldap attribute to search for users with.
 --ldap-host or -H (host)              - Specify ldap host to synchronize from.
 --ldap-pass or -P (pass)              - Specify ldap pass for authentication.
 --log or -L (log)                     - Log script output to specified log file.
 --man or -M                           - View the full script documentation.
 --pass or -p (password)               - Password of user performing actions.
 --synch-full or -s                    - Perform a full synchronization from ldap to sling.
 --synch-full-since or -S (since)      - Perform a full synchronization from ldap to sling using changes since specified time.
 --synch-listed or -l                  - Perform a sychronization of listed users from ldap to sling.
 --synch-listed-since (since)          - Perform a sychronization of listed users from ldap to sling using changes since specified time.
 --upload-user-list (userList)         - Upload user list specified by file userList.
 --url or -U (URL)                     - URL for system being tested against.
 --user or -u (username)               - Name of user to perform any actions as.
 --verbose or -v or -vv or -vvv        - Increase verbosity of output.

Options may be merged together. -- stops processing of options.
Space is not required between options and their arguments.
For full details run: perl $0 --man
EOF

    return 1;
}

#}}}

#{{{ sub man
sub man {

    my ($ldap_synch) = @_;

    print <<'EOF';
LDAP synchronization perl script. Provides a means of synchronizing user
information from an LDAP server into a running sling instance from the command
line. The script also acts as a reference implementation for the LDAPSynch perl
library.

EOF

    $ldap_synch->help();

    print <<"EOF";
Example Usage

* Upload a restricted list of users (one id per line of specified file) to use in synchronizations:

 perl $0 --upload-user-list user_list.txt --sling-host http://localhost:8080 --sling-user admin --sling-pass admin

* Download a previously specified list of users to be synchronized to a specified file:

 perl $0 --download-user-list user_list.txt --sling-host http://localhost:8080 --sling-user admin --sling-pass admin

* Authenticate and perform a full synchronization:

 perl $0 -s -h ldap://ldap.org -b "ou=people,o=ldap,dc=org" -H http://localhost:8080 -u admin -P admin -a "displayname,mail,sn" -A "name,email,surname"
EOF

    return 1;
}



( run in 3.056 seconds using v1.01-cache-2.11-cpan-2398b32b56e )