#!/bin/csh # Copyright 11/09/98 Sun Microsystems, Inc. All Rights Reserved. # "@(#)addnwmapuser 1.1 98/11/09 Sun Microsystems" source ./profile.csh if ( "$4" == "" ) then echo "Usage : $0 NetWare_Server_Name Unix_Name NetWare_User NetWare_User_Password" exit 1 endif # find the netware server segment number to add the map set segno=`$NF_SBIN/findnwsegno $1 $2` if ( "$status" != 0 ) then echo "Add NetWare user map failed : $segno" exit 1 endif set segno=`echo $segno | sed -e "s/ /\+/g"` set temp="$segno" set update=`echo $segno | grep "||"` if ( "$update" == "" ) then # add new user map if ( "$segno" == "1" ) then set ff="File+Servers=$1&segno=$segno&unixuser=$2&nwuser=$3&nwpassword=$4&type=user&default=default&request=Login" else set ff="File+Servers=$1&segno=$segno&unixuser=$2&nwuser=$3&nwpassword=$4&type=user&default=&request=Update+Configuration" endif else # edit existing user map set segno=`echo "$temp" | sed -e "s/||.*//"` set mapped_user=`echo "$temp" | sed -e "s/.*||//"` if ( "$segno" == "1" ) then set ff="File+Servers=$1&MAPPED_USER=$mapped_user&segno=$segno&unixuser=$2&nwuser=$3&nwpassword=$4&type=user&default=default&request=Update+Configuration" else set ff="File+Servers=$1&MAPPED_USER=$mapped_user&segno=$segno&unixuser=$2&nwuser=$3&nwpassword=$4&type=user&default=&request=Update+Configuration" endif endif set len=`echo $ff | awk ' { print length($1) } '` echo "$ff" > /tmp/input.$$ setenv SERVER_PORT 880 setenv REMOTE_HOST localhost setenv REQUEST_METHOD POST #setenv HTTP_ACCEPT 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*' setenv CONTENT_TYPE 'application/x-www-form-urlencoded' setenv CONTENT_LENGTH $len $NF_NCLIB/www/cgi-bin/map.cgi < /tmp/input.$$ > /tmp/map.cgi.$$ sleep 1 rm -f /tmp/input.$$ # restart netcpass set pid=`ps -ef | grep netcpass | grep -v grep | awk ' { print $2 } '` if ( "$pid" != "" ) then kill -9 $pid endif $NF_NCBIN/netcpass >& /dev/null sleep 2 if ( "$temp" == "1" ) then # need to repost rm -f /tmp/map.cgi.$$ set ff="File+Servers=$1&request=Update+Mapped+User" set len=`echo $ff | awk ' { print length($1) } '` echo "$ff" > /tmp/input.$$ setenv SERVER_PORT 880 setenv REMOTE_HOST localhost setenv REQUEST_METHOD POST #setenv HTTP_ACCEPT 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*' setenv CONTENT_TYPE 'application/x-www-form-urlencoded' setenv CONTENT_LENGTH $len $NF_NCLIB/www/cgi-bin/map.cgi < /tmp/input.$$ > /tmp/map.cgi.$$ rm -f /tmp/input.$$ > /dev/null endif set succeed=`grep -iw "$3" /tmp/map.cgi.$$ | grep -iw "$2" | grep -iw "user"` if ( "$succeed" != "" ) then echo "Add entry succeed : from unix user '$2' to NetWare user '$3' on NetWare Server '$1'" rm -f /tmp/map.cgi.$$ >& /dev/null exit 0 else set connect=`grep -w FAILED /tmp/map.cgi.$$` if ( "$connect" != "" ) then echo "Add NetWare user map failed : $connect" else echo "Unable to add the NetWare user map." endif rm -f /tmp/map.cgi.$$ >& /dev/null exit 1 endif