Script to change a user password for GroupWise 2014

 
0 Likes
Here's a script to change a user password.. some comments have been added to hopefully clarify what's going on.

#/bin/bash

# --- ipaddr, port and administrator for gwadmin service
IP=10.10.10.10
PORT=9710
GWADMIN=admin

# ---- Prompt for admin pwd so it isn't revealed in the script
echo "Enter GroupWise Admin Password: "
read ADMINPWD

# --- Prompt for GW userid, his/her postoffice and new pwd
# --- We want the postoffice in case there are duplicate userids in
the sytem
echo "Enter GroupWise UserID for password change: "
read GWID
echo "Enter Post Office for $GWID: "
read PO
echo "Enter new password for $GWID: "
read NEWPWD

#-- build base url for admin service
BASEURL="https://$IP:$PORT/gwadmin-service"

# --- create json data for the new password
DATA="{\"userPassword\":{\"value\":\"$NEWPWD\"}}"

# --- build url to search for the user. the /list/user.csv will
return the user data in csv format.
# --- attrs= returns only the users domain,po and gwid, so we can build
the url to change the pwd
SEARCHURL="$BASEURL/list/user.csv?name=$GWID&postoffice=$PO&attrs=domain,postoffice,name"

# --- use curl to search the admin service for the user,and gawk to
build the proper user url
url=`curl -k --user $GWADMIN:$ADMINPWD $SEARCHURL |gawk
--field-separator=, 'NR!=1 {print
"'$BASEURL'/domains/"$1"/postoffices/"$2"/users/"$3"/clientoptions"}'`

# --- now use curl to change the pwd. note content-type cause were
using a json doc
curl -k --user $GWADMIN:$ADMINPWD -H "Content-Type:application/json" -X
PUT $url --data $DATA
echo "Password changed"
# --- end of script


This is a use at your own risk script.  Please make sure that you have a complete, working backup of your GroupWise system before using.

 

Labels:

How To-Best Practice
Comment List
Related
Recommended