getpwnam question

P

perlUSER

Hello all;
I am writing a perl program to lock the user ID if it exists in a file
that I receive on a daily basis. I could use "lsuser -a account_locked
user_ID" to see whether user_ID is locked or not. If locked then I skip
the record and go to the next record. Is there a perl function to get
this account_locked flag value something like below?

my $userPw = getpwnam($user);
my $home = $userPw -> dir;
my $uid = $userPw -> uid;
my $gecos = $userPw -> gecos;

I tried this but didn't work:

my $account_locked = $userPw -> account_locked;

The above function gives some information but not the
account_locked=true or account_locked=false.

I appreciate any help on this problem.

Thanks in advance.

Regards,
Sri.
 
A

Anno Siegel

perlUSER said:
Hello all;
I am writing a perl program to lock the user ID if it exists in a file
that I receive on a daily basis. I could use "lsuser -a account_locked
user_ID" to see whether user_ID is locked or not. If locked then I skip
the record and go to the next record. Is there a perl function to get
this account_locked flag value something like below?

my $userPw = getpwnam($user);
my $home = $userPw -> dir;
my $uid = $userPw -> uid;
my $gecos = $userPw -> gecos;

I tried this but didn't work:

my $account_locked = $userPw -> account_locked;

The above function gives some information but not the
account_locked=true or account_locked=false.

The property of an account being "locked" is a peculiarity of AIX, it
doesn't exist in other Unix systems. It is stored in the file
/etc/security/user and not in /etc/passwd like other properties of an
account. Consequently, getpwnam() (and other account-related get-functions)
don't know about this property.

You'll have to use the external lsuser command (another AIX specialty) or
parse /etc/security/user yourself to get that info.

Anno
 
J

John W. Krahn

Anno said:
The property of an account being "locked" is a peculiarity of AIX, it
doesn't exist in other Unix systems.

I know that you could lock accounts on DG/UX and I know you can on Linux.

man 1 passwd

Look for the -l switch.

It is stored in the file
/etc/security/user and not in /etc/passwd like other properties of an
account.

In Linux it is stored in the /etc/shadow file. The first character of the
password field is set to '!'.

Consequently, getpwnam() (and other account-related get-functions)
don't know about this property.

You'll have to use the external lsuser command (another AIX specialty) or
parse /etc/security/user yourself to get that info.


John
 
A

Anno Siegel

perlUSER said:
Hello all
I am writing a perl program to lock the user ID if it exists in fil
that I receive on a daily basis. I could use "lsuser - account_locke
user_ID" to see whether user_ID is locked or not. If locked then ski
the record and go to the next record. Is there a perl function t ge
this account_locked flag value something like below

my $userPw = getpwnam($user)
my $home = $userPw -> dir
my $uid = $userPw -> uid
my $gecos = $userPw -> gecos

I tried this but didn't work

my $account_locked = $userPw -> account_locked

The above function gives some information but not th
account_locked=true or account_locked=false
The property of an account being "locked" is a peculiarity of AIX, i
doesn't exist in other Unix systems. It is stored in the fil
/etc/security/user and not in /etc/passwd like other properties of a
account. Consequently, getpwnam() (and other account-relate
get-functions
don't know about this property

You'll have to use the external lsuser command (another AIX specialty
o
parse /etc/security/user yourself to get that info

Ann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top