* Implemented the CREU server command to administratively create user accounts
authorArt Cancro <ajc@citadel.org>
Sun, 3 Mar 2002 06:18:45 +0000 (06:18 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 3 Mar 2002 06:18:45 +0000 (06:18 +0000)
* Added the ability to create new user accounts to <.A>ide <U>seredit

citadel/ChangeLog
citadel/citserver.c
citadel/routines.c
citadel/techdoc/session.txt
citadel/user_ops.c
citadel/user_ops.h

index 1f0e457e40175e5190b7361c1e2585d19841909e..fe3a6ec4f0a9fc1140532acb74499ba244c5f1d9 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 590.122  2002/03/03 06:18:45  ajc
+ * Implemented the CREU server command to administratively create user accounts
+ * Added the ability to create new user accounts to <.A>ide <U>seredit
+
  Revision 590.121  2002/03/03 06:05:16  ajc
  * Split up some of the code in order to prepare for user accounts to be
    administratively created without logging in to them.
@@ -3372,3 +3376,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index b28bb0eef4ca8e9602d90e9cacb54e73a99ccae1..6244d1423487744e130d972438b011a7f23fa191 100644 (file)
@@ -933,6 +933,10 @@ void do_command_loop(void) {
                cmd_newu(&cmdbuf[5]);
                }
 
+       else if (!strncasecmp(cmdbuf,"CREU",4)) {
+               cmd_creu(&cmdbuf[5]);
+               }
+
        else if (!strncasecmp(cmdbuf,"SETP",4)) {
                cmd_setp(&cmdbuf[5]);
                }
index cfe19729f62b745cf64a026ea77f62b2e004a975..007be566c770de5aa3c625e263c250da58963d65 100644 (file)
@@ -121,13 +121,22 @@ void edituser(void)
        int userpurge;
 
        newprompt("User name: ",who,25);
-       sprintf(buf,"AGUP %s",who);
+AGUP:  sprintf(buf,"AGUP %s",who);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0]!='2') {
                scr_printf("%s\n",&buf[4]);
-               return;
+               scr_printf("Do you want to create this user? ");
+               if (yesno()) {
+                       sprintf(buf, "CREU %s", who);
+                       serv_puts(buf);
+                       serv_gets(buf);
+                       if (buf[0] == '2') goto AGUP;
+                       scr_printf("%s\n",&buf[4]);
+                       return;
                }
+               return;
+       }
        extract(who, &buf[4], 0);
        extract(pass, &buf[4], 1);
        flags = extract_int(&buf[4], 2);
index 6d4274365a5ce463878f08de4c075b3a346e75c9..3860b60b2241ca8648c1a97331acfe7d205573d7 100644 (file)
@@ -182,7 +182,7 @@ following parameters are returned:
  
  NEWU   (create NEW User account)
  
- This command creates a new user account and logs it in.  The argument to
+ This command creates a new user account AND LOGS IT IN.  The argument to
 this command will be the name of the account.  No case conversion is done
 on the name.  Note that the new account is installed with a default
 configuration, and no password, so the client should immediately prompt the
@@ -191,6 +191,9 @@ command completes.  This command returns OK if the account was created and
 logged in, or ERROR if another user already exists with this name.  If OK,
 it will also return the same parameters that PASS returns.
  
+ Please note that the NEWU command should only be used for self-service user account
+creation.  For administratively creating user accounts, please use the CREU command.
   
  SETP   (SET new Password)
  
@@ -200,6 +203,20 @@ returns OK, unless the client is not logged in, in which case it will return
 ERROR.
  
    
+ CREU   (CREate new User account)
+ This command creates a new user account AND DOES NOT LOG IT IN.  The argument to
+this command will be the name of the account.  No case conversion is done
+on the name.  Note that the new account is installed with a default
+configuration, and no password.  This command returns OK if the account was created,
+or ERROR if another user already exists with this name.  
+ Please note that CREU is intended to be used for activities in which a system
+administrator is creating user accounts.  For self-service user account creation,
+use the NEWU command.
+  
  LKRN   (List Known Rooms with New messages)
  
  List known rooms with new messages.  If the client is not logged in, ERROR
index 3d22cf86a8d2f0c995d6ab04564fa640f36bd792..7954cfc76f5a8ebdc001b9a5ef32dcaed93d5d11 100644 (file)
@@ -757,7 +757,7 @@ int create_user(char *newusername, int become_user)
 
 
 /*
- * cmd_newu()  -  create a new user account
+ * cmd_newu()  -  create a new user account and log in as that user
  */
 void cmd_newu(char *cmdbuf)
 {
@@ -836,6 +836,45 @@ void cmd_setp(char *new_pw)
        PerformSessionHooks(EVT_SETPASS);
 }
 
+
+/*
+ * cmd_creu()  -  administratively create a new user account (do not log in to it)
+ */
+void cmd_creu(char *cmdbuf)
+{
+       int a;
+       char username[SIZ];
+
+       if (CtdlAccessCheck(ac_aide)) {
+               return;
+       }
+
+       extract(username, cmdbuf, 0);
+       username[25] = 0;
+       strproc(username);
+
+       if (strlen(username) == 0) {
+               cprintf("%d You must supply a user name.\n", ERROR);
+               return;
+       }
+
+       a = create_user(username, 0);
+
+       if (a == 0) {
+               cprintf("%d ok\n", OK);
+               return;
+       } else if (a == ERROR + ALREADY_EXISTS) {
+               cprintf("%d '%s' already exists.\n",
+                       ERROR + ALREADY_EXISTS, username);
+               return;
+       } else {
+               cprintf("%d An error occured creating the user account.\n", ERROR);
+       }
+       rec_log(CL_NEWUSER, username);
+}
+
+
+
 /*
  * get user parameters
  */
index e60ef2a7ce616063f7c635fb126f40b9329aa62a..e8e1338b7f3c792655c7d9fae5f3b28fae1755d6 100644 (file)
@@ -15,6 +15,7 @@ int purge_user (char *pname);
 int create_user (char *newusername, int become_user);
 void do_login(void);
 void cmd_newu (char *cmdbuf);
+void cmd_creu (char *cmdbuf);
 void cmd_setp (char *new_pw);
 void cmd_getu (void);
 void cmd_setu (char *new_parms);