diff -Nur --exclude=CVS asterisk-clean/apps/Makefile asterisk/apps/Makefile
--- asterisk-clean/apps/Makefile	2003-10-26 10:50:49.000000000 -0800
+++ asterisk/apps/Makefile	2003-10-27 10:48:51.000000000 -0800
@@ -24,7 +24,7 @@
      app_authenticate.so app_softhangup.so app_lookupblacklist.so \
      app_waitforring.so app_privacy.so app_db.so app_chanisavail.so \
      app_enumlookup.so app_voicemail2.so app_transfer.so app_setcidnum.so app_cdr.so \
-     app_hasnewvoicemail.so app_sayunixtime.so app_cut.so
+     app_hasnewvoicemail.so app_sayunixtime.so app_cut.so app_setcdruserfield.so
 
 ifneq (${OSARCH},Darwin)
 APPS+=app_intercom.so
diff -Nur --exclude=CVS asterisk-clean/apps/app_setcdruserfield.c asterisk/apps/app_setcdruserfield.c
--- asterisk-clean/apps/app_setcdruserfield.c	1969-12-31 16:00:00.000000000 -0800
+++ asterisk/apps/app_setcdruserfield.c	2003-10-29 13:20:15.000000000 -0800
@@ -0,0 +1,108 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Applictions connected with CDR engine
+ * 
+ * Copyright (C) 2003, Digium
+ *
+ * Justin Huff <jjhuff@mspin.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <sys/types.h>
+#include <asterisk/channel.h>
+#include <asterisk/cdr.h>
+#include <asterisk/module.h>
+#include <asterisk/pbx.h>
+#include <asterisk/logger.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+
+static char *tdesc = "CDR user field apps";
+
+static char *setcdruserfield_descrip = 
+		"SetCDRUserField(value): Set the CDR user field to value\n";
+		
+static char *setcdruserfield_app = "SetCDRUserField";
+static char *setcdruserfield_synopsis = "Set the CDR user field";
+
+static char *appendcdruserfield_descrip = 
+		"AppendCDRUserField(value): Append value to the CDR user field\n";
+		
+static char *appendcdruserfield_app = "AppendCDRUserField";
+static char *appendcdruserfield_synopsis = "Append to the CDR user field";
+
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
+static int setcdruserfield_exec(struct ast_channel *chan, void *data)
+{
+	struct localuser *u;
+	int res = 0;
+	
+	LOCAL_USER_ADD(u)
+	if (chan->cdr && data) 
+	{
+		ast_cdr_setuserfield(chan, (char*)data);
+	}
+
+	LOCAL_USER_REMOVE(u);
+	
+	return res;
+}
+
+static int appendcdruserfield_exec(struct ast_channel *chan, void *data)
+{
+	struct localuser *u;
+	int res = 0;
+	
+	LOCAL_USER_ADD(u)
+	if (chan->cdr && data) 
+	{
+		ast_cdr_appenduserfield(chan, (char*)data);
+	}
+
+	LOCAL_USER_REMOVE(u);
+	
+	return res;
+}
+
+int unload_module(void)
+{
+	int res;
+	STANDARD_HANGUP_LOCALUSERS;
+	res = ast_unregister_application(setcdruserfield_app);
+	res |= ast_unregister_application(appendcdruserfield_app);
+	return res;
+}
+
+int load_module(void)
+{
+	int res;
+	res = ast_register_application(setcdruserfield_app, setcdruserfield_exec, setcdruserfield_synopsis, setcdruserfield_descrip);
+	res |= ast_register_application(appendcdruserfield_app, appendcdruserfield_exec, appendcdruserfield_synopsis, appendcdruserfield_descrip);
+
+	return res;
+}
+
+char *description(void)
+{
+	return tdesc;
+}
+
+int usecount(void)
+{
+	int res;
+	STANDARD_USECOUNT(res);
+	return res;
+}
+
+char *key()
+{
+	return ASTERISK_GPL_KEY;
+}
diff -Nur --exclude=CVS asterisk-clean/cdr/cdr_csv.c asterisk/cdr/cdr_csv.c
--- asterisk-clean/cdr/cdr_csv.c	2003-05-29 21:41:18.000000000 -0700
+++ asterisk/cdr/cdr_csv.c	2003-10-29 13:27:16.000000000 -0800
@@ -28,6 +28,7 @@
 #define DATE_FORMAT "%Y-%m-%d %T"
 
 /* #define CSV_LOGUNIQUEID 1 */
+/* #define CSV_LOGUSERFIELD 1 */
 
 #include <stdio.h>
 #include <string.h>
@@ -60,6 +61,7 @@
   "disposition",    	// ANSWERED, NO ANSWER, BUSY
   "amaflags",       	// DOCUMENTATION, BILL, IGNORE etc, specified on a per channel basis like accountcode.
   "uniqueid",           // unique call identifier
+  "userfield"		// user field set via SetCDRUserField
 */
 
 static char *desc = "Comma Separated Values CDR Backend";
@@ -126,6 +128,7 @@
 
 static int build_csv_record(char *buf, int len, struct ast_cdr *cdr)
 {
+
 	buf[0] = '\0';
 	/* Account code */
 	append_string(buf, cdr->accountcode, len);
@@ -164,6 +167,10 @@
 	/* Unique ID */
 	append_string(buf, cdr->uniqueid, len);
 #endif
+#ifdef CSV_LOGUSERFIELD
+	/* append the user field */
+	append_string(buf, cdr->userfield,len);	
+#endif
 	/* If we hit the end of our buffer, log an error */
 	if (strlen(buf) < len - 5) {
 		/* Trim off trailing comma */
diff -Nur --exclude=CVS asterisk-clean/cdr.c asterisk/cdr.c
--- asterisk-clean/cdr.c	2003-09-16 21:21:56.000000000 -0700
+++ asterisk/cdr.c	2003-10-29 12:45:04.000000000 -0800
@@ -345,6 +345,27 @@
 	return 0;
 }
 
+int ast_cdr_setuserfield(struct ast_channel *chan, char *userfield)
+{
+	struct ast_cdr *cdr = chan->cdr;
+
+	if (cdr)
+		strncpy(cdr->userfield, userfield, sizeof(cdr->userfield) - 1);
+	return 0;
+}
+
+int ast_cdr_appenduserfield(struct ast_channel *chan, char *userfield)
+{
+	struct ast_cdr *cdr = chan->cdr;
+
+	if (cdr)
+	{
+		int len = strlen(cdr->userfield);
+		strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1);
+	}
+	return 0;
+}
+
 int ast_cdr_update(struct ast_channel *c)
 {
 	struct ast_cdr *cdr = c->cdr;
diff -Nur --exclude=CVS asterisk-clean/include/asterisk/cdr.h asterisk/include/asterisk/cdr.h
--- asterisk-clean/include/asterisk/cdr.h	2003-09-12 09:51:35.000000000 -0700
+++ asterisk/include/asterisk/cdr.h	2003-10-29 12:19:08.000000000 -0800
@@ -28,7 +28,9 @@
 //! AMA Flags
 #define AST_CDR_OMIT				(1)
 #define AST_CDR_BILLING				(2)
-#define AST_CDR_DOCUMENTATION		(3)
+#define AST_CDR_DOCUMENTATION			(3)
+
+#define AST_MAX_USER_FIELD			256
 
 struct ast_channel;
 
@@ -70,6 +72,8 @@
 	int posted;				
         /* Unique Channel Identifier */
         char uniqueid[32];
+	/* User field */
+	char userfield[AST_MAX_USER_FIELD];
 };
 
 typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
@@ -224,6 +228,12 @@
 extern char *ast_cdr_flags2str(int flags);
 
 extern int ast_cdr_setaccount(struct ast_channel *chan, char *account);
+
+
+extern int ast_cdr_setuserfield(struct ast_channel *chan, char *userfield);
+extern int ast_cdr_appenduserfield(struct ast_channel *chan, char *userfield);
+
+
 /* Update CDR on a channel */
 extern int ast_cdr_update(struct ast_channel *chan);
 
