(FILECREATED " 6-Sep-85 22:45:33" {ERIS}<LISPCORE>LIBRARY>NSMAINTAIN.;23 17980  

      changes to:  (FNS NSMAINTAIN \NSMT.ADD.ALIAS \NSMT.JOIN.GROUP \NSMT.LEAVE.GROUP 
			\NSMT.LIST.OBJECTS \NSMT.SHOW.DOMAIN \NSMT.TELLABOUT \NSMT.TYPE.ENTRY 
			\NSMT.TYPE.MEMBERS \NSMT.PRINT.LIST \NSMT.HUMANIZE.ENTRY)
		   (VARS NSMAINTAINCOMS)

      previous date: "10-Aug-85 02:24:05" {ERIS}<LISPCORE>LIBRARY>NSMAINTAIN.;22)


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT NSMAINTAINCOMS)

(RPAQQ NSMAINTAINCOMS ((FNS NSMAINTAIN \NSMT.ADD.ALIAS \NSMT.ADD.GROUP \NSMT.ADD.USER 
			    \NSMT.CHANGE.DOMAIN \NSMT.CHANGE.PASSWORD \NSMT.HUMANIZE.ENTRY 
			    \NSMT.JOIN.GROUP \NSMT.LEAVE.GROUP \NSMT.LIST.OBJECTS \NSMT.PRINT.LIST 
			    \NSMT.READFNAME \NSMT.READREMARK \NSMT.SHOW.DOMAIN \NSMT.TELLABOUT)
	(FNS \NSMT.CHANGE.REMARK \NSMT.CHANGE.GROUP.COMPONENT \NSMT.TYPE.ENTRY \NSMT.TYPE.MEMBERS)
	(FILES CLEARINGHOUSE)))
(DEFINEQ

(NSMAINTAIN
  [LAMBDA NIL                                                (* lmm " 6-Sep-85 22:31")
    (PROG (CHGROUPS LASTNAME LASTGROUP LASTSTRING CMD)
          (DECLARE (SPECVARS CHGROUPS LASTNAME LASTGROUP LASTSTRING))
          (do (ERSETQ (PROGN (TERPRI T)
			     (CLEARBUF T T)
			     (SELECTQ (ASKUSER NIL NIL "CH: "
					       (QUOTE (Add% Alias Add% Group Add% Member Add% User 
								  Change% Group% Access 
								  Change% Password Change% Remark 
								  Add% Self Remove% Self List% Users 
								  List% Groups List% Objects 
								  List% FileServers List% MailServers 
								  List% Clearinghouses
								  (Quit "" CONFIRMFLG T)
								  Remove% Alias 
								  Add% Domain% Administrator 
								  Remove% Domain% Administrator 
								  Remove% Member Remove% User 
								  Show% Domain Describe Type% Entry 
								  List% Members Type% Members %))
					       T)
				      (Add% Alias (\NSMT.ADD.ALIAS))
				      (Add% Group (\NSMT.ADD.GROUP))
				      (Add% Member (\NSMT.CHANGE.GROUP.COMPONENT
						     (FUNCTION CH.ADD.MEMBER)
						     (QUOTE ADD)))
				      (Add% User (\NSMT.ADD.USER))
				      (Change% Password (\NSMT.CHANGE.PASSWORD))
				      (Change% Remark (\NSMT.CHANGE.REMARK))
				      (Add% Self (\NSMT.JOIN.GROUP))
				      (Remove% Self (\NSMT.LEAVE.GROUP))
				      (List% Users (\NSMT.LIST.OBJECTS (QUOTE USER)))
				      (List% Groups (\NSMT.LIST.OBJECTS (QUOTE MEMBERS)))
				      (List% Objects (\NSMT.LIST.OBJECTS))
				      [List% FileServers (PROG NIL
							       (\NSMT.LIST.OBJECTS (QUOTE FILESERVER]
				      (List% MailServers (\NSMT.LIST.OBJECTS (QUOTE MAIL.SERVICE)))
				      (List% Clearinghouses (\NSMT.LIST.OBJECTS (QUOTE 
									    CLEARINGHOUSE.SERVICE)))
				      (Quit (RETFROM (QUOTE NSMAINTAIN)))
				      [Remove% Alias (LET ((ALIAS (\NSMT.READFNAME " alias: ")))
						          (COND
							    (ALIAS (CH.DELETE.ALIAS ALIAS]
				      (Add% Domain% Administrator (\NSMT.CHANGE.DOMAIN
								    (FUNCTION 
								      CH.ADD.MEMBER.TO.DOMAIN.ACL)
								    (QUOTE ADD)))
				      (Remove% Domain% Administrator (\NSMT.CHANGE.DOMAIN
								       (FUNCTION 
								 CH.DELETE.MEMBER.FROM.DOMAIN.ACL)
								       (QUOTE REMOVE)))
				      (Remove% Member (\NSMT.CHANGE.GROUP.COMPONENT
							(FUNCTION CH.DELETE.MEMBER)
							(QUOTE REMOVE)))
				      (Remove% User (LET ((USER (\NSMT.READFNAME ": ")))
						         (CH.DELETE.OBJECT USER)))
				      (Show% Domain (\NSMT.SHOW.DOMAIN))
				      (Describe (\NSMT.TYPE.ENTRY))
				      (Type% Entry (\NSMT.TYPE.ENTRY))
				      (List% Members (\NSMT.TYPE.MEMBERS))
				      (Type% Members (\NSMT.TYPE.MEMBERS))
				      [% ((LAMBDA NIL
					      (TERPRI T)
					      (USEREXEC (QUOTE ←←]
				      (SHOULDNT])

(\NSMT.ADD.ALIAS
  [LAMBDA NIL                                                (* lmm " 6-Sep-85 21:34")
    (PROG NIL
          (CH.CREATE.ALIAS (OR (\NSMT.READFNAME " alias: ")
			       (RETURN))
			   (OR (\NSMT.READFNAME " object: " LASTSTRING)
			       (RETURN])

(\NSMT.ADD.GROUP
  (LAMBDA NIL                                                (* jwo: " 8-Jul-85 14:27")
    (LET ((GROUP (\NSMT.READFNAME ": " LASTSTRING)))
         (if GROUP
	     then (SETQ RESULT (CH.CREATE.OBJECT GROUP))
		  (if (AND (LISTP RESULT)
			   (EQ (CAR RESULT)
			       (QUOTE ERROR)))
		      then (printout T " " (CADDR RESULT)
				     "." T)
		    else (TERPRI T)
			 (CH.ADD.ITEM.PROPERTY GROUP (QUOTE USERGROUP)
					       (PROMPTFORWORD "Remark: " RESULT NIL T NIL NIL
							      (CHARCODE (CR)))
					       (QUOTE STRING))
			 (CH.ADD.GROUP.PROPERTY GROUP (QUOTE MEMBERS)
						(bind NEWMEMB while (SETQ NEWMEMB
								      (PROGN (TERPRI T)
									     (\NSMT.READFNAME 
										       "Member: ")))
						   collect NEWMEMB))
			 (for ADM in (bind NEWADM while (SETQ NEWADM (PROGN (TERPRI T)
									    (\NSMT.READFNAME 
										"Administrator: ")))
					collect NEWADM)
			    do (CH.ADD.MEMBER.TO.PROPERTY.ACL GROUP (QUOTE MEMBERS)
							      (QUOTE Administrators)
							      ADM))
			 (for SELFER in (bind NEWSELFER while (SETQ NEWSELFER (PROGN (TERPRI T)
										     (\NSMT.READFNAME
										       
									       "SelfController: ")))
					   collect NEWSELFER)
			    do (CH.ADD.MEMBER.TO.PROPERTY.ACL GROUP (QUOTE MEMBERS)
							      (QUOTE selfControllers)
							      SELFER))
			 (printout T "Done." T))))))

(\NSMT.ADD.USER
  (LAMBDA NIL                                                (* jwo: " 9-Aug-85 11:42")
    (PROG (NAME UPNAME PASS RESULT DESC)
          (DECLARE (USEDFREE LASTNAME LASTSTRING))
          (COND
	    ((SETQ NAME (\NSMT.READFNAME " name: " LASTNAME))
	      (COND
		((OR (NULL (SETQ PASS (PROMPTFORWORD " with password: " NIL NIL T (QUOTE *))))
		     (NOT (STREQUAL PASS (PROMPTFORWORD " (retype password) " NIL NIL T (QUOTE *)))))
		  (printout T " xxx" T))
		(T (SETQ DESC (PROMPTFORWORD " description: " RESULT NIL T NIL NIL (CHARCODE
					       (CR))))
		   (PRIN1 "..." T)
		   (COND
		     ((NEQ (CAR (SETQ RESULT (CH.CREATE.OBJECT NAME)))
			   (QUOTE ERROR))
		       (CH.ADD.ITEM.PROPERTY NAME (QUOTE USER)
					     DESC
					     (QUOTE STRING))
		       (if (AS.CREATE.PASSWORDS NAME (\ENCRYPT.PWD PASS))
			   then (printout T " done" T)
			 else (printout T " couldn't create passwords for user" T)))
		     (T (printout T RESULT))))))))))

(\NSMT.CHANGE.DOMAIN
  (LAMBDA (CHACCESSFN OPERATION)                             (* jwo: "24-Jun-85 13:08")
    (PROG (CHNAMETYPE DOMAIN INDIVIDUAL RESULT)
          (DECLARE (SPECVARS CHNAMETYPE)
		   (USEDFREE LASTNAME LASTSTRING LASTSTRING))
          (COND
	    ((AND (SETQ INDIVIDUAL (\NSMT.READFNAME " name: " LASTNAME))
		  (SETQ DOMAIN (\NSMT.READFNAME (SELECTQ OPERATION
							 (ADD " to domain: ")
							 (REMOVE " from domain: ")
							 (SHOULDNT))
						LASTSTRING T)))
	      (PRIN1 "..." T)
	      (SETQ RESULT (APPLY* CHACCESSFN DOMAIN (QUOTE Administrators)
				   INDIVIDUAL))
	      (printout T (COND
			  ((EQ RESULT T)
			    "done")
			  (T RESULT))
			T)
	      (SETQ LASTNAME INDIVIDUAL)
	      (SETQ LASTSTRING DOMAIN))))))

(\NSMT.CHANGE.PASSWORD
  (LAMBDA NIL                                                (* jwo: " 9-Aug-85 12:09")
    (PROG (NAME UPNAME PASS PASSKEY RESULT)
          (DECLARE (USEDFREE LASTNAME LASTSTRING))
          (COND
	    ((SETQ NAME (\NSMT.READFNAME " for user: " USERNAME))
	      (COND
		((OR (NULL (SETQ PASS (PROMPTFORWORD " to be: " NIL NIL T (QUOTE *))))
		     (NOT (STREQUAL PASS (PROMPTFORWORD " (retype password) " NIL NIL T (QUOTE *)))))
		  (printout T " xxx" T))
		(T (PRIN1 "..." T)
		   (if (STREQUAL USERNAME NAME)
		       then (COND
			      ((EQ (SETQ RESULT (AS.CHANGE.PASSWORDS (\ENCRYPT.PWD PASS)))
				   T)
				(printout T " done" T)
				(SETPASSWORD (QUOTE NS::)
					     (MKATOM (SETQ LASTNAME (SETQ LASTSTRING NAME)))
					     PASS))
			      (T (printout T RESULT)))
		     else (COND
			    ((EQ (SETQ RESULT (AS.DELETE.PASSWORDS NAME))
				 T)
			      (if (AS.CREATE.PASSWORDS NAME (\ENCRYPT.PWD PASS))
				  then (printout T " done" T)
				else (printout T " couldn't create user keys" T)))
			    (T (printout T (CADDR RESULT)
					 T)))))))))))

(\NSMT.HUMANIZE.ENTRY
  [LAMBDA (FNAME CHPLIST)                                    (* lmm " 6-Sep-85 22:24")
                                                             (* Called by \NSMT.TYPE.ENTRY to make sense out of the 
							     gook in the various clearinghouse properties.)
    (PROG (ALIASLST)
          (TERPRI T)
          (TERPRI T)
          (COND
	    ((SETQ ALIASLST (CH.LIST.ALIASES.OF FNAME))
	      (printout T "Aliases: " ALIASLST T)))
          (for P in CHPLIST do (\NSMT.TELLABOUT FNAME P])

(\NSMT.JOIN.GROUP
  [LAMBDA NIL                                                (* lmm " 6-Sep-85 22:06")
    (PROG (GROUP RESULT)
          (DECLARE (USEDFREE LASTGROUP LASTSTRING))
          (COND
	    ((SETQ GROUP (\NSMT.READFNAME " to: " LASTGROUP))
	      (PRIN1 "..." T)
	      (SETQ RESULT (CH.ADD.SELF GROUP (QUOTE MEMBERS)))
	      (printout T (COND
			  ((NEQ (AND (LISTP RESULT)
				     (CAR RESULT))
				(QUOTE ERROR))
			    "done")
			  (T (CADDR RESULT)))
			T)
	      (SETQ LASTSTRING (SETQ LASTGROUP GROUP])

(\NSMT.LEAVE.GROUP
  [LAMBDA NIL                                                (* lmm " 6-Sep-85 22:06")
    (PROG (GROUP RESULT)
          (DECLARE (USEDFREE LASTGROUP LASTSTRING))
          (COND
	    ((SETQ GROUP (\NSMT.READFNAME " from: " LASTGROUP))
	      (PRIN1 "..." T)
	      (SETQ RESULT (CH.DELETE.SELF GROUP (QUOTE MEMBERS)))
	      (printout T (COND
			  ((NEQ (AND (LISTP RESULT)
				     (CAR RESULT))
				(QUOTE ERROR))
			    "done")
			  (T (CADDR RESULT)))
			T)
	      (SETQ LASTSTRING (SETQ LASTGROUP GROUP])

(\NSMT.LIST.OBJECTS
  [LAMBDA (CHP)                                              (* lmm " 6-Sep-85 22:16")

          (* * (given a clearinghouse property, lookup all objects with a user-specified pattern that have that property))


    (PROG (FNAME)
          (COND
	    ((SETQ FNAME (\NSMT.READFNAME " by pattern: " LASTNAME))
	      (PRIN1 "..." T)
	      (\NSMT.PRINT.LIST (CH.LIST.OBJECTS FNAME CHP])

(\NSMT.PRINT.LIST
  [LAMBDA (LST FILE PREFIX)                                  (* lmm " 6-Sep-85 22:16")
    (MAPRINT LST FILE PREFIX NIL ", ")
    (TERPRI FILE])

(\NSMT.READFNAME
  (LAMBDA (PROMPT DEFAULT DOMAINFLG)                         (* jwo: "24-Jun-85 13:05")
    (LET ((SUFFIX (COND
		    (DOMAINFLG CH.DEFAULT.ORGANIZATION)
		    (T CH.DEFAULT.DOMAIN)))
	  (NAME (PROMPTFORWORD PROMPT DEFAULT NIL T NIL NIL (CHARCODE (EOL)))))
         (COND
	   ((NULL NAME)
	     (printout T " xxx" T))
	   ((NOT (STRPOS ":" NAME))
	     (printout T ":" SUFFIX)
	     (SETQ NAME (CONCAT NAME ":" SUFFIX))))
     NAME)))

(\NSMT.READREMARK
  (LAMBDA (USER)                                             (* jwo: "24-Jun-85 11:19")
    (CH.RETRIEVE.ITEM USER (QUOTE USER)
		      (QUOTE STRING))))

(\NSMT.SHOW.DOMAIN
  [LAMBDA NIL                                                (* lmm " 6-Sep-85 22:16")
    (DECLARE (USEDFREE (LASTSTRING)))
    (LET ((DOMAIN (\NSMT.READFNAME " domain: " LASTSTRING T)))
         (COND
	   (DOMAIN (TERPRI T)
		   (\NSMT.PRINT.LIST (CH.RETRIEVE.DOMAIN.ACL DOMAIN (QUOTE Administrators))
				     T "Administrators: "])

(\NSMT.TELLABOUT
  [LAMBDA (FNAME CHP)                                        (* lmm " 6-Sep-85 22:24")
                                                             (* Called by \NSMT.HUMANIZE.ENTRY to show one 
							     particular property.)
    (SELECTQ (SETQ CHP (OR (CH.NUMBER.TO.PROPERTY CHP)
			   CHP))
	     (MEMBERS (\NSMT.PRINT.LIST (CH.RETRIEVE.PROPERTY.ACL FNAME (QUOTE MEMBERS)
								  (QUOTE Administrators))
					T "Owners: ")
		      (\NSMT.PRINT.LIST (CH.RETRIEVE.PROPERTY.ACL FNAME (QUOTE MEMBERS)
								  (QUOTE selfControllers))
					T "Friends: ")
		      (SETQ LASTGROUP FNAME))
	     (USERGROUP (printout T "Description: " (CADR (CH.RETRIEVE.ITEM FNAME (QUOTE USERGROUP)
									    (QUOTE STRING)))
				  T))
	     (MAILBOXES (printout T "Mailbox at: " [COURIER.FETCH (CLEARINGHOUSE . MAILBOX.VALUES)
								  MAIL.SERVICE of
								  (CADR (CH.RETRIEVE.ITEM
									  FNAME
									  (QUOTE MAILBOXES)
									  (QUOTE MAILBOX.VALUES]
				  T))
	     (FILE.SERVICE (printout T "File service" T))
	     (PRINT.SERVICE (printout T "Print service" T))
	     (USER (printout T "Remark: " (CADR (CH.RETRIEVE.ITEM FNAME (QUOTE USER)
								  (QUOTE STRING)))
			     T))
	     (MAILSERVICE (printout T "Mail Server" T))
	     (WORKSTATION (printout T "A workstation" T))
	     (NETWORK (printout T "A network" T))
	     (CLEARINGHOUSE.SERVICE (printout T "Clearinghouse service" T))
	     (USERDATA (printout T "Home file service: " [COURIER.FETCH (CLEARINGHOUSE . 
									  USERDATA.VALUE)
									FILE.SERVICE of
									(CADR (CH.RETRIEVE.ITEM
										FNAME
										(QUOTE USERDATA)
										(QUOTE USERDATA.VALUE]
				 T))
	     (ADDRESS.LIST (printout T "Network addresses: " (CADR (CH.RETRIEVE.ITEM FNAME
										     (QUOTE 
										     ADDRESS.LIST)
										     (QUOTE 
									     NETWORK.ADDRESS.LIST)))
				     T))
	     (AUTHENTICATION.LEVEL)
	     (AUTHENTICATION.KEYS)
	     (7)
	     (USERPASSWORD)
	     (FILESERVER)
	     (PRINTSERVER)
	     (printout T FNAME " also has property " CHP T])
)
(DEFINEQ

(\NSMT.CHANGE.REMARK
  (LAMBDA NIL                                                (* jwo: "23-Jul-85 07:52")
    (PROG (USER RESULT NEWREMARK)
          (DECLARE (USEDFREE LASTSTRING))
          (if (SETQ USER (\NSMT.READFNAME " for user: " LASTSTRING))
	      then (if (SETQ RESULT (CADR (\NSMT.READREMARK USER)))
		       then (printout T " to be (type remark, terminate with <cr>)" T)
			    (if (SETQ NEWREMARK (PROMPTFORWORD "Remark: " RESULT NIL T NIL NIL
							       (CHARCODE (CR))))
				then (PRIN1 "..." T)
				     (SETQ RESULT (CH.DELETE.PROPERTY USER (QUOTE USER)))
				     (if (EQ (CAR RESULT)
					     (QUOTE ERROR))
					 then (printout T (CDR RESULT))
				       else (SETQ RESULT (CH.ADD.ITEM.PROPERTY USER (QUOTE USER)
									       NEWREMARK
									       (QUOTE STRING)))
					    (if (EQ (CAR RESULT)
						    (QUOTE ERROR))
						then (printout T (CDR RESULT)))
					    (SETQ LASTSTRING USER)))
		     else (printout T " not a user!"))))))

(\NSMT.CHANGE.GROUP.COMPONENT
  (LAMBDA (CHACCESSFN OPERATION)                             (* jwo: " 7-Jul-85 17:06")
    (PROG (GROUP INDIVIDUAL RESULT)
          (DECLARE (USEDFREE LASTNAME LASTGROUP LASTSTRING))
          (COND
	    ((AND (SETQ INDIVIDUAL (\NSMT.READFNAME " name: " LASTNAME))
		  (SETQ GROUP (\NSMT.READFNAME (SELECTQ OPERATION
							(ADD " to group: ")
							(REMOVE " from group: ")
							(SHOULDNT))
					       LASTGROUP)))
	      (PRIN1 "..." T)
	      (SETQ RESULT (APPLY* CHACCESSFN GROUP (QUOTE MEMBERS)
				   INDIVIDUAL))
	      (printout T (COND
			  ((EQ RESULT T)
			    "done")
			  (T RESULT))
			T)
	      (SETQ LASTNAME INDIVIDUAL)
	      (SETQ LASTSTRING (SETQ LASTGROUP GROUP)))))))

(\NSMT.TYPE.ENTRY
  [LAMBDA NIL                                                (* lmm " 6-Sep-85 21:45")
    (PROG (FNAME)
          (DECLARE (SPECVARS FNAME))
          (if (SETQ FNAME (\NSMT.READFNAME " name: " LASTSTRING))
	      then (PRIN1 "..." T)
		   (if (SETQ FNAME (CH.LOOKUP.OBJECT FNAME))
		       then (SETQ CHPLIST (CADR (CH.LIST.PROPERTIES FNAME)))
			    (\NSMT.HUMANIZE.ENTRY FNAME CHPLIST)
			    (SETQ LASTSTRING FNAME)
		     else (printout T T "Name not found" T])

(\NSMT.TYPE.MEMBERS
  [LAMBDA NIL                                                (* lmm " 6-Sep-85 22:16")
    (PROG (NAME)
          (DECLARE (USEDFREE LASTGROUP LASTSTRING))
          (COND
	    ((SETQ NAME (\NSMT.READFNAME " of group: " (OR LASTGROUP LASTSTRING)))
	      (PRIN1 "..." T)
	      (\NSMT.PRINT.LIST (CH.RETRIEVE.MEMBERS NAME (QUOTE MEMBERS))
				T)
	      (SETQ LASTGROUP (SETQ LASTSTRING NAME])
)
(FILESLOAD CLEARINGHOUSE)
(PUTPROPS NSMAINTAIN COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (955 14860 (NSMAINTAIN 965 . 4001) (\NSMT.ADD.ALIAS 4003 . 4311) (\NSMT.ADD.GROUP 4313
 . 5915) (\NSMT.ADD.USER 5917 . 7032) (\NSMT.CHANGE.DOMAIN 7034 . 7877) (\NSMT.CHANGE.PASSWORD 7879 . 
9137) (\NSMT.HUMANIZE.ENTRY 9139 . 9710) (\NSMT.JOIN.GROUP 9712 . 10320) (\NSMT.LEAVE.GROUP 10322 . 
10936) (\NSMT.LIST.OBJECTS 10938 . 11383) (\NSMT.PRINT.LIST 11385 . 11563) (\NSMT.READFNAME 11565 . 
12060) (\NSMT.READREMARK 12062 . 12253) (\NSMT.SHOW.DOMAIN 12255 . 12649) (\NSMT.TELLABOUT 12651 . 
14858)) (14861 17873 (\NSMT.CHANGE.REMARK 14871 . 16011) (\NSMT.CHANGE.GROUP.COMPONENT 16013 . 16830) 
(\NSMT.TYPE.ENTRY 16832 . 17397) (\NSMT.TYPE.MEMBERS 17399 . 17871)))))
STOP