#!/h/COE/Comp/PERL5/bin/perl -T -I/h/COE/lib  -w
#-
 # Copyright (C) 2002, Federal Linux Systems
 # License: GNU Lesser General Public License, v2.1
#- 

use strict;
use Coe;

my $PRGM="COE_get_user_id";
my $VERSION="1.1.4.1";

if (@ARGV == 0) {
	&useage;
   	exit 202;
} 

sub useage {
   	print "Useage: COE_get_user_id [options]  \n";
}

my $arg1;
my $coedat;
my $COEDAT;
my $scope;
my $u;
my $uid=0;
my $username;

my @uid;

while ( @ARGV > 0 ){
	$arg1=cleanString(shift,1);
	if ("$arg1" eq "-h") {
		useage;
   		exit 0;
	} elsif ("$arg1" eq "-H") {
		coeMan("COE_COMP/UserMgmt/docs/man/$PRGM");
   		exit 0;
	} elsif ("$arg1" eq "-V") {
   		print "VERSION: $VERSION\n";
   		exit 0;
	} else {
   		$username=$arg1;
		$scope=cleanString(shift,1);
	}
}

if ("$scope" eq "l" || "$scope" eq "local" ) {
	$scope="local";
} elsif ("$scope" eq "g" || "$scope" eq "global" ) {
	$scope="global";
} else {
	useage;
	exit 202;
}

$coedat=coeFileConv "COE_USER/$scope/Profiles/.User.dat";

$COEDAT=readFile ($coedat);
while (<$COEDAT>) { if (/:$username:/) {$uid=$_;}}
close $COEDAT;

$_=$uid;
@uid=split(':');
print "$uid[0]\n";

if ("$uid[0]" eq "0" ) {
	exit 203;
} else {
	exit 0;
}