X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/2860a1762ae0bd578b662954d80d23d4db22e752..686214e677408dd6e9f93941338df914d1c9164a:/clients/moira/user.c diff --git a/clients/moira/user.c b/clients/moira/user.c index 02a7b9b5..69ab7b73 100644 --- a/clients/moira/user.c +++ b/clients/moira/user.c @@ -32,6 +32,8 @@ RCSID("$Header$"); void CorrectCapitalization(char **name); char **AskUserInfo(char **info, Bool name); struct mqelem *GetUserInfo(int type, char *name1, char *name2); +static void PrintLogin(char **info); +struct mqelem *GetUserBySponsor(char *type, char *name); #define LOGIN 0 #define UID 1 @@ -47,6 +49,8 @@ struct mqelem *GetUserInfo(int type, char *name1, char *name2); #define DEFAULT_CLASS "?" #define DEFAULT_WINCONSOLESHELL "cmd" +#define DEFAULT_WINHOMEDIR "[DFS]" +#define DEFAULT_WINPROFILEDIR "[DFS]" /* Function Name: UserState * Description: Convert a numeric state into a descriptive string. @@ -103,7 +107,7 @@ static void PrintUserName(char **info) static void PrintUserInfo(char **info) { - char name[BUFSIZ], buf[BUFSIZ]; + char name[BUFSIZ], buf[BUFSIZ], sponsor[BUFSIZ]; int status; sprintf(name, "%s, %s %s", info[U_LAST], info[U_FIRST], info[U_MIDDLE]); @@ -115,9 +119,16 @@ static void PrintUserInfo(char **info) sprintf(buf, "Class: %-25s Windows Console Shell: %-10s", info[U_CLASS], info[U_WINCONSOLESHELL]); Put_message(buf); + sprintf(sponsor, "%s %s", info[U_SPONSOR_TYPE], info[U_SPONSOR_NAME]); + sprintf(buf, "Sponsor: %-23s Expiration date: %s", sponsor, info[U_EXPIRATION]); + Put_message(buf); sprintf(buf, "Account is: %-20s MIT ID number: %s", UserState(atoi(info[U_STATE])), info[U_MITID]); Put_message(buf); + sprintf(buf, "Windows Home Directory: %s", info[U_WINHOMEDIR]); + Put_message(buf); + sprintf(buf, "Windows Profile Directory: %s", info[U_WINPROFILEDIR]); + Put_message(buf); status = atoi(info[U_STATE]); if (status == 0 || status == 2) { @@ -154,6 +165,11 @@ static char **SetUserDefaults(char **info) info[U_COMMENT] = strdup(""); info[U_SIGNATURE] = strdup(""); info[U_SECURE] = strdup("0"); + info[U_WINHOMEDIR] = strdup(DEFAULT_WINHOMEDIR); + info[U_WINPROFILEDIR] = strdup(DEFAULT_WINPROFILEDIR); + info[U_SPONSOR_TYPE] = strdup("NONE"); + info[U_SPONSOR_NAME] = strdup("NONE"); + info[U_EXPIRATION] = strdup(""); info[U_MODTIME] = info[U_MODBY] = info[U_MODWITH] = info[U_END] = NULL; info[U_CREATED] = info[U_CREATOR] = NULL; return info; @@ -300,6 +316,24 @@ char **AskUserInfo(char **info, Bool name) if (GetValueFromUser("Comments", &info[U_COMMENT]) == SUB_ERROR) return NULL; + if (GetValueFromUser("Windows Home Directory", &info[U_WINHOMEDIR]) == + SUB_ERROR) + return NULL; + + if (GetValueFromUser("Windows Profile Directory", &info[U_WINPROFILEDIR]) == + SUB_ERROR) + return NULL; + + if (GetTypeFromUser("User's sponsor type", "ace_type", &info[U_SPONSOR_TYPE]) + == SUB_ERROR) + return NULL; + if (strcmp(info[U_SPONSOR_TYPE], "NONE") && + GetValueFromUser("Sponsor's Name", &info[U_SPONSOR_NAME]) == SUB_ERROR) + return NULL; + + if (GetValueFromUser("Expiration date", &info[U_EXPIRATION]) == SUB_ERROR) + return NULL; + state = atoi(info[U_STATE]); if (!name || state == 0 || state == 2) { @@ -1141,3 +1175,61 @@ void PrintReservationTypes(void) FreeQueue(QueueTop(top)); } +int UserBySponsor(int argc, char **argv) +{ + char buf[BUFSIZ], temp_buf[BUFSIZ], *type, *name; + struct mqelem *top; + + type = strdup("USER"); + if (GetTypeFromUser("Type of sponsor", "ace_type", &type) == SUB_ERROR) + return DM_NORMAL; + + sprintf(buf, "Name of %s", type); + name = strdup(user); + if (GetValueFromUser(buf, &name) == SUB_ERROR) + return DM_NORMAL; + + switch (YesNoQuestion("Do you want a recursive search (y/n)", FALSE)) + { + case TRUE: + sprintf(temp_buf, "R%s", type); /* "USER to "RUSER", etc. */ + free(type); + type = strdup(temp_buf); + break; + case FALSE: + break; + default: + return DM_NORMAL; + } + + top = GetUserBySponsor(type, name); + Loop(top, PrintLogin); + + FreeQueue(top); + return DM_NORMAL; +} + +static void PrintLogin(char **info) +{ + char buf[BUFSIZ]; + + sprintf(buf, "Login: %s", info[U_NAME]); + Put_message(buf); +} + +struct mqelem *GetUserBySponsor(char *type, char *name) +{ + char *args[2]; + struct mqelem *elem = NULL; + int status; + + args[0] = type; + args[1] = name; + if ((status = do_mr_query("get_user_account_by_sponsor", 2, args, StoreInfo, + &elem))) + { + com_err(program_name, status, " in get_user_account_by_sponsor"); + return NULL; + } + return QueueTop(elem); +}