+ /* Check to see if this OpenID is already in the database */
+
+ cdboi = cdb_fetch(CDB_OPENID, claimed_id, strlen(claimed_id));
+ if (cdboi != NULL) {
+ if ( (long)*cdboi->ptr == who->usernum ) {
+ cdb_free(cdboi);
+ CtdlLogPrintf(CTDL_INFO, "%s already associated; no action is taken\n", claimed_id);
+ return(0);
+ }
+ else {
+ cdb_free(cdboi);
+ CtdlLogPrintf(CTDL_INFO, "%s already belongs to another user\n", claimed_id);
+ return(3);
+ }
+ }
+
+ /* Not already in the database, so attach it now */
+
+ cdb_store(CDB_OPENID, claimed_id, strlen(claimed_id), &who->usernum, sizeof(long));
+ CtdlLogPrintf(CTDL_INFO, "%s has been associated with %s (%ld)\n",
+ claimed_id, who->fullname, who->usernum);
+ return(0);