#
# @(#)78	1.3  src/examples/acl_mgr/acl_mgr_unsetup.dcecp, examples.src, os2dce21.dss, 960602a.1  3/17/96  15:51:06
#
# COMPONENT_NAME:  examples.src
#
# FILE NAME: acl_mgr_unsetup.dcecp
#
# FUNCTIONS: Acl_mgr application de-installation dcecp script.
#
# USAGE: dcecp acl_mgr_unsetup.dcecp <cdsentry> -p <cell_admin passwd>
#
# ORIGINS: 27/72
#
# (C) COPYRIGHT International Business Machines Corp. 1995
#  All Rights Reserved
#  Licensed Materials - Property of IBM
#
#  US Government Users Restricted Rights - Use, duplication or
#  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
# @OSF_COPYRIGHT@
# COPYRIGHT NOTICE
# Copyright (c) 1990, 1991, 1992, 1993, 1994 Open Software Foundation, Inc.
# ALL RIGHTS RESERVED (DCE).  See the file named COPYRIGHT.DCE in the
# src directory for the full copyright text.
#
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

proc run_cmd {cmd} {

   set sts  [catch {uplevel $cmd} answer]

   if {$sts == 0} {
       return 0
   } else {
	puts "$answer"
	return 1
   }
}

# Check argument count and print the usage if necessary.

   if { $argc < 3 } {
      error "Usage: dcecp acl_mgr_unsetup.dcecp <cdsentry> -p <cell_admin passwd>"
   }

# Parse command line args: put cdsentry in entry, password in pwd

   scan $argv "%s -p %s" entry pwd

# Steps:
#	- Login as cell_admin
#	- Delete group acl_servers
#	- Delete server principal acl_server
#	- Delete client principal acl_client
#	- Delete keytab file
#	- Delete CDS namespace and entries


# Logging in.
   puts "Logging in..."
   run_cmd {login cell_admin -password $pwd}

   puts "Deleting group."
   puts "group delete {acl_servers} "
   run_cmd {group delete {acl_servers}}

# deleting principal also deletes the account
   puts "Deleting principals and accounts."
   puts "principal delete {acl_server} "
   puts "principal delete {acl_client} "
   run_cmd {principal delete {acl_server}}
   run_cmd {principal delete {acl_client}}

   puts "Deleting CDS entries."
   puts "rpcentry delete $entry/acl_server_entry"
   run_cmd {rpcentry delete $entry/acl_server_entry}
   puts "directory delete $entry"
   run_cmd {directory delete $entry}

   puts "Logging out."
   run_cmd {logout}

# need to be "self" in dce for keytab operations
   puts "Deleting keytab file."
   puts "keytab delete aclmgr"
   run_cmd {keytab delete aclmgr}
