#!/usr/local/bin/perl # # $Header: dbPasswordSetting.pl 09-dec-2004.19:40:25 dkjain Exp $ # # dbPasswordSetting.pl # # Copyright (c) 2004, Oracle. All rights reserved. # # NAME # dbPasswordSetting.pl - # # DESCRIPTION # # # NOTES # # # MODIFIED (MM/DD/YY) # dkjain 11/24/04 - Adding profile value to be inserted # dkjain 11/01/04 - Fixed unable to connect # dkjain 10/18/04 - Output number for UNLIMITED # dkjain 10/08/04 - dkjain_esa_impl_init # dkjain 10/08/04 - Creation # require "emd_common.pl"; require "semd_common.pl"; require "$ENV{EMDROOT}/sysman/admin/scripts/db/esaDbUtils.pl"; require "$ENV{EMDROOT}/sysman/admin/scripts/db/esaUtils.pl"; my %stdinArgs = get_stdinvars(); my $username = $stdinArgs{"EM_TARGET_USERNAME"}; my $password = $stdinArgs{"EM_TARGET_PASSWORD"}; my $oracleHome = $ENV{EM_TARGET_ORACLE_HOME}; my $address = $ENV{EM_TARGET_ADDRESS}; my $role = $ENV{EM_TARGET_ROLE}; my $mode = 0; if($role =~ /SYSDBA/i) { $mode = 2; } elsif($role =~ /SYSOPER/i) { $mode = 4; } my $dsn = "dbi:Oracle:" ; my $property1 = "password_life_time"; my $property2 = "password_reuse_max"; my $property3 = "password_reuse_time"; my $property4 = "password_lock_time"; my $property5 = "password_grace_time"; my $limit_col = "LIMIT" ; my $profile_col = "PROFILE"; my $table = "dba_profiles"; my $resource_name = "resource_name"; my $num = 0; my $dbh = open_db_connection("dbi:Oracle:", "$username@".$address,$password,$mode); get_value_profile("PASSWORD_REUSE_MAX",$property2); get_value_profile("PASSWORD_LOCK_TIME",$property4); $num = 1; get_value_profile("PASSWORD_LIFE_TIME",$property1); get_value_profile("PASSWORD_REUSE_TIME",$property3); get_value_profile("PASSWORD_GRACE_TIME",$property5); close_db_connection($dbh); sub get_value_profile{ my ($rsc_name_value,$property) = @_ ; my $sth ; my @row ; $sth = $dbh->prepare_cached("SELECT $limit_col,$profile_col FROM $table where $resource_name = '$rsc_name_value'") or die "em_error=Couldnt prepare statement:$dbh->errstr\n"; $sth->execute() or die "em_error=Couldn't execute statement:$sth->errstr\n"; while (@row = $sth->fetchrow_array()) { if($num){ print "em_result=$property|$row[0]|$row[1]\n"; } else { print "em_result=$property|32977|$row[1]\n"; } } }