~ubuntu-branches/ubuntu/natty/otrs2/natty-updates

« back to all changes in this revision

Viewing changes to bin/otrs.setPassword

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2007-04-14 17:58:55 UTC
  • mto: (20.1.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: package-import@ubuntu.com-20070414175855-9ne0w01yu1q44ch0
Tags: upstream-2.1.7
ImportĀ upstreamĀ versionĀ 2.1.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl -w
2
2
# --
3
3
# otrs.setPassword - Changes or Sets password for a user
4
 
# Copyright (C) 2002 Atif Ghaffar <aghaffar@developer.ch>
5
 
# $Id: otrs.setPassword,v 1.7 2003/01/23 22:50:09 martin Exp $
6
 
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
7
 
# the enclosed file COPYING for license information (GPL). If you
8
 
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
 
4
# Copyright (C) 2001-2006 OTRS GmbH, http://otrs.org/
 
5
# --
 
6
# $Id: otrs.setPassword,v 1.9 2006/08/26 17:22:05 martin Exp $
 
7
# --
 
8
# This program is free software; you can redistribute it and/or modify
 
9
# it under the terms of the GNU General Public License as published by
 
10
# the Free Software Foundation; either version 2 of the License, or
 
11
# (at your option) any later version.
 
12
#
 
13
# This program is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
# GNU General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU General Public License
 
19
# along with this program; if not, write to the Free Software
 
20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
9
21
# --
10
22
 
 
23
# use ../ as lib location
11
24
use File::Basename;
12
25
use FindBin qw($RealBin);
13
26
use lib dirname($RealBin);
14
27
use lib dirname($RealBin)."/Kernel/cpan-lib";
15
28
 
16
 
unless ($ARGV[1]){
17
 
    print "$FindBin::Script username password";
18
 
    print "\n";
19
 
    exit;
20
 
}
21
 
 
22
29
use strict;
 
30
use Getopt::Std;
23
31
use Kernel::Config;
24
32
use Kernel::System::Log;
25
33
use Kernel::System::DB;
26
34
use Kernel::System::User;
27
35
 
28
 
# --
29
 
# create common objects 
30
 
# --
 
36
my $VERSION = '$Revision: 1.9 $';
 
37
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
 
38
 
 
39
my %Opts = ();
 
40
getopt('h', \%Opts);
 
41
if ($Opts{'h'}) {
 
42
    print "otrs.setPassword <Revision $VERSION> - set a new agent password\n";
 
43
    print "Copyright (c) 2001-2006 OTRS GmbH, http://otrs.org/\n";
 
44
    print "usage: otrs.setPassword user password\n";
 
45
    exit 1;
 
46
}
 
47
 
 
48
# create common objects
31
49
my %CommonObject = ();
32
50
$CommonObject{ConfigObject} = Kernel::Config->new(%CommonObject);
33
 
$CommonObject{LogObject}    = Kernel::System::Log->new(%CommonObject, LogPrefix => 'otrs.setPassword');
 
51
$CommonObject{LogObject}    = Kernel::System::Log->new(
 
52
    %CommonObject,
 
53
    LogPrefix => 'otrs.setPassword',
 
54
);
34
55
$CommonObject{DBObject}     = Kernel::System::DB->new(%CommonObject);
35
56
$CommonObject{UserObject}   = Kernel::System::User->new(%CommonObject);
36
57
 
37
 
 
38
 
 
39
 
my %Param;
40
 
undef %Param;
 
58
my $User = shift;
 
59
my $Pw = shift;
 
60
 
 
61
if (!$User) {
 
62
    print STDERR "ERROR: need user ARG[1]\n";
 
63
    exit (1);
 
64
}
 
65
if (!$Pw) {
 
66
    print STDERR "ERROR: need password ARG[1]\n";
 
67
    exit (1);
 
68
}
41
69
 
42
70
# user id of the person Changing the record
43
 
$Param{UserID}='1';
44
 
 
45
 
$Param{UserLogin}=$ARGV[0];
46
 
$Param{PW}=$ARGV[1];
47
 
 
48
 
 
49
 
$CommonObject{UserObject}->SetPassword(%Param);
50
 
 
51
 
# --
 
71
$CommonObject{UserObject}->SetPassword(
 
72
    UserLogin => $User,
 
73
    PW => $Pw,
 
74
);
 
75
 
52
76
exit (0);