+ Post New Thread
Results 1 to 8 of 8
Coding Thread, MYLGFL Automated password resets in Coding and Web Development; I knocked this script up this morning because the teachers are trying to force teachers to start using their emails, ...
  1. #1

    Join Date
    Nov 2007
    Location
    Preston
    Posts
    98
    Thank Post
    2
    Thanked 4 Times in 4 Posts
    Rep Power
    14

    MYLGFL Automated password resets

    I knocked this script up this morning because the teachers are trying to force teachers to start using their emails, trouble is half of them have used it once and forgotten their pw's. This script is just a mass password reset at the moment, but i will be adding more features soon. If anyone is interested i will keep you updated. Anyway, thoughts and improvements are welcome

    PHP Code:
    #!/usr/bin/perl
    #mylgfl script - reset all passwords
    #by josh hall for BBEC

    use strict;
    use 
    warnings;
    use 
    Getopt::Long;
    use 
    LWP::UserAgent;
    use 
    HTTP::Request::Common;

    my %options;
    GetOptions( \%options,    'user=s',
                  
    'pass=s',
                  
    'domain=s',
                  
    'password=s',
                );

    help() unless $options{'domain'};

    my $username $options{'user'} . '@' $options{'domain'};

    my $ua LWP::UserAgent->new();
    $ua->cookie_jar({});
    $ua->agent('Mozilla/5.0');
    $ua->env_proxy();
    push @{ $ua->requests_redirectable }, 'POST';

    #ok now we need to login
    my $check $ua->request(GET 'http://www.lancsngfl.ac.uk/email-admin/login.php');

    $check $ua->request(POST 'http://www.lancsngfl.ac.uk/email-admin/login.php',
                   [ do => 
    'login',
                     
    user => $username,
                     
    password => $options{'pass'},
                     
    submit => 1,
                   ],
                 );

    die 
    "You are not logged in\n" unless $check->content =~ /Logged in as/;

    #grab all the usernames
    $check $ua->request(GET 'http://www.lancsngfl.ac.uk/email-admin/view.php');
    print 
    $check->content();
    my @users $check->content() =~ /<td>(\w+)@[a-z\.]+<\/td>/g;

    #reset all users
    for my $user (@users) {
        print 
    "Resetings User: $user\n";
        
    edituser($user$options{'password'})
    }

    sub edituser {
    my ($username$password) = @_;
    my ($surname$initial) = $username =~ /(\w+)([a-z0-9])$/;
    my $check $ua->request(POST 'http://www.lancsngfl.ac.uk/email-admin/edit.php',
                [ 
    task => 'editSingle',
                  
    uid => $username,
                  
    forename => $initial,
                  
    surname => $surname,
                  
    password => $password,
                  
    password2 => $password,
                ],
            );
    }

    sub help {
    print <<
    "ENDDOC";
    --------------------------------------------
    MYLGFL all user Password reset version 0.1
    Code grabs all usernames from view
    .php and then
    proceeds to reset the passwords to one you specified
    .

    Usage:
    perl mylgflreset.pl
        
    -user LGFLADMIN 
        
    -pass LGFLPASSWORD 
        
    -domain SCHOOLDOMAIN 
        
    -password DEFAULTPASSWORD
    ENDDOC
    exit;


  2. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,803
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224
    no https then?

  3. #3

    Join Date
    Nov 2007
    Location
    Preston
    Posts
    98
    Thank Post
    2
    Thanked 4 Times in 4 Posts
    Rep Power
    14
    https://www.lancsngfl.ac.uk/email-admin/login.php

    Not Found

    The requested URL /email-admin/login.php was not found on this server.
    Apache Server at www.lancsngfl.ac.uk Port 443


  4. #4

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,803
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224
    Lovely. :P

  5. #5

    Join Date
    Nov 2007
    Location
    Preston
    Posts
    98
    Thank Post
    2
    Thanked 4 Times in 4 Posts
    Rep Power
    14
    the client login lacks https too, pretty silly. Btw, i have a few moodle scripts too if anyone is interested i can dig them out.

  6. #6

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,808
    Thank Post
    1,476
    Thanked 592 Times in 444 Posts
    Rep Power
    168
    Do you fancy posting this stuff over in the lancs forum

    www.lancsngfl.ac.uk/forums/dg

    as its just specfic to us?

    regards

    Simon

  7. #7

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,803
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224
    To be fair, it might not be. LancsNGFL was trying to sell the system to other LEAs/RBCs.

  8. #8

    Join Date
    Nov 2007
    Location
    Preston
    Posts
    98
    Thank Post
    2
    Thanked 4 Times in 4 Posts
    Rep Power
    14
    Feel free to post it on my behalf. Im looking at it from more of a techie aspect cos tbh, lancsngfl should be adding features like this to their apps ;-)

SHARE:
+ Post New Thread

Similar Threads

  1. Automated CMIS Backup
    By mark80 in forum MIS Systems
    Replies: 10
    Last Post: 30th September 2008, 12:40 PM
  2. MySQL automated backup
    By contink in forum *nix
    Replies: 6
    Last Post: 4th January 2008, 09:35 PM
  3. Cachepilot error with myLGFL
    By philtomo-25 in forum Windows
    Replies: 2
    Last Post: 27th June 2007, 10:45 AM
  4. Automated PC Naming
    By Mr_M_Cox in forum Windows
    Replies: 8
    Last Post: 31st May 2007, 06:40 PM
  5. Automated Mac Address Retrieval
    By Kained in forum How do you do....it?
    Replies: 12
    Last Post: 27th March 2007, 03:25 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •