Verifying Duplicate user names > how are you

Verifying Duplicate user names > how are you

Post by Logan Sh » Fri, 13 Jan 1995 07:36:32




>I was wondering if anyone out there has a specific system
>in place for verifying / catching duplicate user names
>before actually using them.

>I mean, of course, other than vi /etc/passwd, then /uname.

Well, here's a short script that will list the real name of any users
that exist, and give a message for users which don't.  Its error code
is the number of listed users that don't exist.

        #! /usr/local/bin/perl

        $notfound = 0;

                {

                        { print "$user ($info[6])\n"; }
                else
                        {
                        print "$user is not a known user\n";
                        $notfound++;
                        }
                }

        exit $notfound;

If I call it vrfyuser, and run the command

        vrfyuser bill logan

I get the output

        bill is not a known user
        logan (Logan Shaw)

It would be easy to use this in a new user script, as in:

        #! /bin/sh

        echo -n "Enter the new user name: "
        read username

        if vrfyuser $username
        then
                echo "User $username already exists!"
                exit 5
        fi

        # now, actually create the user

Hope that helps...

Adios,
  Logan
--
Logan Shaw, Unix System Administrator
"Everything is a struggle in Unix"  -Dave Keenan

 
 
 

1. Verifying Duplicate user names > how are you

Duplicate UIDs:

awk -F: '{
            if (length(array[$3]) > 0) {
                printf("UID = %d; %s, %s\n", $3, array[$3], $1)
                }
            array[$3]=$1
            }' /etc/passwd

LOGNAMES can be done the same way -- with applicable changes
(change $3 to $1).

|> I was wondering if anyone out there has a specific system
|> in place for verifying / catching duplicate user names
|> before actually using them.
|>
|> I mean, of course, other than vi /etc/passwd, then /uname.
|>
|> Thanx,
|>  __________________________________________________________
|> |J. Wayne Hall            | The crows seemed to be calling |
|> |Systems Administrator    | his name, thought Caw.  -  JH  |
|> |Motorola,_Austin,_TX_____|________________________________|
|>  `` If I spokerola for Motorola, I wouldn`t be brokerola ''

--
Disclaimer: I don't speak for Martin Marietta or the EPA.
----------------------------------------------------------

P.O. Box 14365, MD-4501-1B, Research Triangle Park, NC 27709  

2. Solaris NDIS Wrapper Toolkit and usb wifi dongle

3. How to change a users name (r->connection->user) in a module

4. Anyone install Linux (red hat 8.0) on Asus P4PE motherboard?

5. Qube3 user administration - length of user name > 12

6. Solaris 2.4 and OS/2 Lan Server

7. user id -> user name?

8. FTP problem

9. scoadmin -> Account Manager -> Users -> Add New Users breaks /etc/password symlink

10. fixing localhost -> DNS Server -> NAMED -> NDC -> NOTFOUND

11. |Q| Problems with "who am i" reporting incorrect user name.

12. duplicating an iso9660 cd (cd-r -> file -> cd-r)

13. >>> named won't return rootservers