Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding NIS+ users

Status
Not open for further replies.

DedeMole

Programmer
Aug 30, 2001
45
US
Hi..
Can anyone tell me how to add NIS+ users to my server AND to my clients.... I'm very new to being a Solaris 8 LAN administrator... The server is setup with NIS+ and I think so are the workstations. I'm running Solaris 8 on all the machines.. I don't know NIS+ at all so I'm very confused on how to set up a group called Students with users called stud01 to stud12.... I know I have to do something to the server but I have no clue what and I think I have to setup something on the clients, but don't know what... Any and all help is greatly appriciated.

thanks
 
my addnisplususer.sh
Code:
#!/bin/ksh
#************* addnisusers.sh ***************
# addnisuser.sh - ksh script for add user to
# NIS+ without Solstice AdminSuite
#********************************************
EUID=`id|awk -F\( '{print substr($1,5)}'`
if [ $EUID = 0 ] ; then
# get the domainname (minus the trailing . if necessary
  DNAME=`domainname | xargs -I {} basename {} "\."`

#
# Variables need to be gathered to create a new user.
# Notably the Group (to get the GID), the UID,
#   the Comment, the Shell and the Password
#
  echo "GROUPS: \c"
  niscat group.org_dir|nawk -F: '{print $1" "}'|xargs
  echo "GROUP: [grp1]\c"
  read GROUP 
  GROUP=${GROUP:-"grp1"}
  GID=`niscat group.org_dir|grep ^$GROUP:|nawk -F: '{print $3}'`
  if [ -z $GID ]
  then 
    echo Group $GROUP does not exist !!!
    exit
  fi
  echo "USERS: \c"
  niscat passwd.org_dir|grep :$GID:|nawk -F: '{print $1}'|xargs
  echo "NAME: \c"
  read NAME
  echo "IDS: \c"
  niscat passwd.org_dir|grep :$GID:|nawk -F: '{print $3}'|sort -n|xargs
  echo "ID: \c"
  read ID
  echo "REAL NAME: \c"
  read COMMENT
  echo "SHELL: [/bin/csh] \c"
  read SHELL
  SHELL=${SHELL:-"/bin/csh"}
  echo "PASSWORD: \c"
  stty -echo
  read PASS
  stty echo
#
# All variables should now have been gathered
#
  CODE=`perl -e '
    srand;
    $s1= ($rnd=rand(62)) > 9 ? $rnd > 25 ? $rnd + 49 : $rnd + 17 : $rnd;
    $s2= ($rnd=rand(62)) > 9 ? $rnd > 25 ? $rnd + 49 : $rnd + 17 : $rnd;
    print crypt($ARGV[0], chr($s1+48) . chr($s2+48));
  ' $PASS`

#
# HNAME is the host server for the home directory
# EXPHOME is the directory path on the host server for home directories
#
  case $GROUP in
	grp1) EXPHOME=/export/grp1home;
             HNAME=svr1;;
	grp2) EXPHOME=/export/grp2home;
             HNAME=svr1;;
	grp3) EXPHOME=/export/grp3home;
             HNAME=svr2;;
  esac

  echo ""

  nistbladm -a key=$NAME value=$HNAME:$EXPHOME/$NAME auto_home.org_dir > /dev/null
  nistbladm -a name=$NAME passwd=$CODE uid=$ID gid=$GID gcos="$COMMENT" shell=$SHELL home=/home/$NAME passwd.org_dir > /dev/null
  nisaddcred -p $ID -P $NAME.$DNAME. -l $PASS local > /dev/null
  nisaddcred -p unix.$ID@$DNAME -P $NAME.$DNAME. -l $PASS des > /dev/null
  nischown $NAME [name=$NAME],passwd.org_dir > /dev/null
  nischmod n-r,w-r,g+r [name=$NAME],passwd.org_dir > /dev/null
  nistbladm -u passwd=n-r,w-r,g+r passwd.org_dir > /dev/null

  if [ "x$HNAME" = "x`uname -n`" ] ; then
    echo "     mkdir -p $EXPHOME/$NAME 2>/dev/null
     cp /etc/skel/.[a-z]* $EXPHOME/$NAME
     chown -R $NAME:$GROUP $EXPHOME/$NAME
    " ;
  else
    echo "On Server $HNAME:
     mkdir -p $EXPHOME/$NAME 2>/dev/null
     cp /etc/skel/.[a-z]* $EXPHOME/$NAME
     chown -R $NAME:$GROUP $EXPHOME/$NAME
    "
  fi

else
  echo "You must be root"
fi
#******** end of addnisuser.sh *********

you do not need to modify the clients.
because of how my site works we have 2 servers that have home directories, and peoples home directories are created by which group they're in.

this script is the easiest way i've found for adding users at the prompt.
 
jad
thank you thank you thank you.... I'm going now to try this out... Oooooo thank you.... I'll let you know soon...

dede
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top