- status = admin_call(ADMIN_ADD_NEW_KEY_ATTR, login, "",
- "", uid_buf);
-
- if (status) {
- if (status == ADMIN_SERVER_ERROR) {
- printf("Server error: %s\n", admin_errmsg);
-
- if (strcmp(admin_errmsg,
- "Principal already in kerberos database.") ==0)
- status = UREG_LOGIN_USED;
+int find_user(message)
+ struct msg *message; /* Formatted packet structure */
+/* This routine verifies that a user is allowed to register by finding
+ him/her in the SMS database. It returns the status of the SMS
+ query that it calls. */
+{
+#define GUBN_ARGS 2 /* Arguements needed by get_user_by_name */
+ char *q_name; /* Name of query */
+ int q_argc; /* Number of arguments for query */
+ char *q_argv[GUBN_ARGS]; /* Arguments to query */
+ int status = SUCCESS; /* Query return status */
+
+ struct save_queue *queue; /* Queue to hold SMS data */
+ struct db_data *data; /* Structure for data for one tuple */
+ short verified = FALSE; /* Have we verified the user? */
+
+ /* Zero the mit_id field in the formatted packet structure. This
+ being zeroed means that no user was found. */
+ bzero(message->db.mit_id,sizeof(message->db.mit_id));
+
+ if (status == SUCCESS)
+ {
+ /* Get ready to make an SMS query */
+ q_name = "get_user_by_name";
+ q_argc = GUBN_ARGS; /* #defined in this routine */
+ q_argv[0] = message->first;
+ q_argv[1] = message->last;
+
+ /* Create queue to hold information */
+ queue = sq_create();
+
+ /* Do it */
+ status = sms_query(q_name,q_argc,q_argv,db_callproc,(char *)queue);
+
+#ifdef DEBUG
+ fprintf(stderr," %d returned by get_user_by_name\n",status);
+#endif
+
+ if (status == SMS_SUCCESS)
+ {
+ /* Traverse the list, freeing data as we go. If sq_get_data()
+ returns zero if there is no more data on the queue. */
+ while (sq_get_data(queue,&data))
+ {
+ if (!verified)
+ /* parse_encrypted returns zero on success */
+ verified = (parse_encrypted(message,data) == SUCCESS);
+ free((char *)data);