Re: [Arsperl-users] Can you change the remedy user's password in ARSperl?
Brought to you by:
jeffmurphy
|
From: Pittman, T. <Tim...@re...> - 2007-07-31 19:28:37
|
Sure. Here is a subroutine from a web page that I made that changes a
user's password using ARSPerl in a cgi script. Basically ars_SetEntry
can take the password as a parameter and it will encrypt it once it's in
the database. =20
sub changeit {
if ($newpwd ne $cnewpwd) {
print "<span class=3D'greet'>";
print "<h2>Passwords did not match. Try
again.<br></h2>";
print "<a href=3D",$ENV{SCRIPT_NAME},">Click here to
retry</a>";
print "</span>\n";
exit;
}
print "Changing password on $server...<br>\n";
my $userSchema =3D 'User';
(%uf =3D ars_GetFieldTable($ctrl, $userSchema)) ||
&errorHandler($ars_errstr);
$q=3Dsprintf "'%d' =3D \"%s\"", $uf{"Login Name"}, $loginname;
(my $qual =3D ars_LoadQualifier($ctrl,$userSchema,$q)) or
&errorHandler("error in ars_LoadQualifier: $ars_errstr");
=09
(%userList =3D ars_GetListEntry($ctrl,$userSchema, $qual, 0, 0))
|| &errorHandler("User lookup died: $ars_errstr");
#(%userList =3D ars_GetListEntry($ctrl,$userSchema, $qual, 0)) ||
&errorHandler("User lookup died: $ars_errstr");
my $count=3Dkeys %userList;
if ($count !=3D 1) {
print "<span class=3D'greet'>";
print "Major problem in Remedy. Duplicate User Name.
Contact the helpdesk.\n";
print "</span>\n";
return 1;
} else {
while (my($entry_id, $desc) =3D each %userList) {
(%user =3D
ars_GetEntry($ctrl,$userSchema,$entry_id))=20
or &errorHandler("** ERROR retrieving
user information: $ars_errstr\n");
(my $rtnCode =3D ars_SetEntry($ctrl, $userSchema,
$entry_id, 0,
$uf{"Password"}, $newpwd)) or=20
die "Could not update user
password for $fullname due to $ars_errstr\n";
}
}
print "<h2>Password changed</h2>\n";
}
Tim Pittman
Project Engineer
Respironics, Inc.
=20
-----Original Message-----
From: ars...@ar...
[mailto:ars...@ar...] On Behalf Of Jeff Murphy
Sent: Tuesday, July 31, 2007 2:42 PM
To: ARSperl User Discussion
Subject: Re: [Arsperl-users] Can you change the remedy user's password
in ARSperl?
Van De Kerk, David - PHX wrote:
>=20
>=20
> Hi,
>=20
> I am very new to ARSperl.
>=20
> Is it possible to change the password of the user you log in with?
>=20
I've never tried it via Perl, but you should be able to change the
password by setting the appropriate record/field in the User form.
jeff
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Arsperl-users mailing list
Ars...@ar...
https://lists.sourceforge.net/lists/listinfo/arsperl-users
|