#!/usr/local/bin/perl
# 
# $Header: dbOsAuthentication.pl 12-jan-2006.15:31:13 dsukhwal Exp $
#
# dbOsAuthentication.pl
# 
# Copyright (c) 2004, 2006, Oracle. All rights reserved.  
#
#    NAME
#      dbOsAuthentication.pl - <one-line expansion of the name>
#
#    DESCRIPTION
#      <short description of component this file declares/defines>
#
#    NOTES
#      <other useful comments, qualifications, etc.>
#
#    MODIFIED   (MM/DD/YY)
#    dsukhwal    01/12/06 - correct registry handling
#    dsukhwal    11/16/05 - include util script:bug 4725586 
#    dsukhwal    07/04/05 - support flood control 
#    dkjain      07/03/05 - Fixd the bug 4422016 
#    dkjain      11/08/04 - corrected env parameter name for target oraclehome 
#    dkjain      10/08/04 - dkjain_esa_impl_init
#    dkjain      10/08/04 - Creation
# 

if(!($^O eq "MSWin32")){
    exit(0);#This metric is defined for Windows
}
require "$ENV{EMDROOT}/sysman/admin/scripts/db/esaUtils.pl";
if(!compareNegInf(0,$ENV{'OSAUTHMAX'}))
{
  exit ;
}

my $oracleHome = $ENV{EM_TARGET_ORACLE_HOME};
#Assuming that oracle.key file will always be there in bin directory of Oracle Home.
my $o_key_file= "$oracleHome\\bin\\oracle.key";
my $oracle_key_name ;
  
open ( FILE, $o_key_file) or die print "em_error=Cannot open file: $!\n";
chomp ( ($oracle_key_name = <FILE>) );
$oracle_key_name =~ s/\\/\//g;
my $property="osauth_prefix_domain" ;
my $data ;

$pound= $Registry->Delimiter("/");
$oraKey= $Registry->{"HKEY_LOCAL_MACHINE/$oracle_key_name"};

my %hash =  %$oraKey;
my %subhash = $hash{"/OSAUTH_PREFIX_DOMAIN"};
foreach $newKey (keys %subhash){
  $data = $newKey;	
}
if(((defined $data)) && (!($data eq "")) ){
  print "em_result=$property|$data\n";
}

