SUMMARY: How do I determine if id is valid login?

From: Laurent Duperval (laurent@grafnetix.com)
Date: Mon Aug 12 1996 - 10:59:56 CDT


Hello,

Thank you to everyone who answered. The basic approach requires using
ypmatch (nismatch on NIS+) or greping on /etc/passwd (/etc/shadow if
you are root and use shadow passwords) and piping it to:

awk -F: '{print $2}'

This will return an empty string if the login doesn't exist and it will
return '*' or LK or NP if there is no password for that account.

If you use Perl, there is a function called getpwnam() which will get
the same information.

My thanks to:

Jeff Popp
Roy Rapoport
Charles Gagnon
Edward Grimm
judyh@nikko.com
Nicky Ayoub
Walter Moore
Lee Frank

The original request:

>
> I'm writing a script in which I need to determine if a given word is a
> valid login name. It has to be a name which requires a password, e.g.
> lp, uucp and the like would be considered invalid. Is there a way to
> determine this?
>

-- 
Laurent Duperval, Systems Analyst       Grafnetix Systems Inc.
Tel: (514) 861-3389                     777, de la Commune Ouest
Fax: (514) 866-6206                     Suite 101, Montreal, Qc
Laurent@Grafnetix.COM                   Canada, H3C 1Y1
URL: http://www.Grafnetix.COM/~laurent
nt
Status: RO



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:07 CDT