--- a/apps/reg_agent/RegistrationAgent.cpp
+++ b/apps/reg_agent/RegistrationAgent.cpp
@@ -138,10 +138,10 @@ void RegThread::create_registration(RegI
       di_args.push("reg_agent");             //sess_link
       di_args.push(ri.proxy.c_str());
       di_args.push(ri.contact.c_str());
-			
+
       registrar_client_i->invoke("createRegistration", di_args, reg_handle);
       if (reg_handle.size()) 
-	ri.handle = reg_handle.get(0).asCStr();
+        ri.handle = reg_handle.get(0).asCStr();
     }
   }
 }
--- a/core/AmUACAuth.cpp
+++ b/core/AmUACAuth.cpp
@@ -7,8 +7,6 @@ UACAuthCred::UACAuthCred(const string& r
 			 const string& pwd)
   : realm(realm), user(user), pwd(pwd) { }
 
-
-
 AmUACAuth::AmUACAuth() { }
 
 AmUACAuth::~AmUACAuth() { }
--- a/core/ampi/UACAuthAPI.h
+++ b/core/ampi/UACAuthAPI.h
@@ -48,10 +48,11 @@ class UACAuthCred
   string pwd;
   UACAuthCred();
   UACAuthCred(const string& realm,
-	      const string& user,
-	      const string& pwd);
+        const string& user,
+        const string& pwd);
 };
 
+
 class CredentialHolder
 : public virtual AmObject {
  public:
--- a/apps/db_reg_agent/DBRegAgent.cpp
+++ b/apps/db_reg_agent/DBRegAgent.cpp
@@ -312,22 +312,24 @@ bool DBRegAgent::loadRegistrations() {
       case REG_STATUS_FAILED:  // try again
 	{
 	  createRegistration(subscriber_id,
-			     (string)row[COLNAME_USER],
-			     (string)row[COLNAME_PASS],
-			     (string)row[COLNAME_REALM],
-			     contact_uri
-			     );
+           (string)row[COLNAME_AUTH_USER],
+           (string)row[COLNAME_USER],
+           (string)row[COLNAME_PASS],
+           (string)row[COLNAME_REALM],
+           contact_uri
+           );
 	  scheduleRegistration(subscriber_id);
 	}; break;
 
       case REG_STATUS_ACTIVE:
 	{
 	  createRegistration(subscriber_id,
-			     (string)row[COLNAME_USER],
-			     (string)row[COLNAME_PASS],
-			     (string)row[COLNAME_REALM],
-			     contact_uri
-			     );
+           (string)row[COLNAME_AUTH_USER],
+           (string)row[COLNAME_USER],
+           (string)row[COLNAME_PASS],
+           (string)row[COLNAME_REALM],
+           contact_uri
+           );
 
 	  time_t dt_expiry = now_time;
 	  if (row[COLNAME_EXPIRY] != mysqlpp::null) {
@@ -368,11 +370,12 @@ bool DBRegAgent::loadRegistrations() {
 	  DBG("Scheduling Deregister of registration %ld %s@%s", subscriber_id,
 	      ((string)row[COLNAME_USER]).c_str(), ((string)row[COLNAME_REALM]).c_str());
 	  createRegistration(subscriber_id,
-			     (string)row[COLNAME_USER],
-			     (string)row[COLNAME_PASS],
-			     (string)row[COLNAME_REALM],
-			     contact_uri
-			     );
+           (string)row[COLNAME_AUTH_USER],
+           (string)row[COLNAME_USER],
+           (string)row[COLNAME_PASS],
+           (string)row[COLNAME_REALM],
+           contact_uri
+           );
 	  scheduleDeregistration(subscriber_id);
 	};
       }
@@ -390,12 +393,14 @@ bool DBRegAgent::loadRegistrations() {
 
 /** create registration in our list */
 void DBRegAgent::createRegistration(long subscriber_id,
-				    const string& user,
-				    const string& pass,
-				    const string& realm,
-				    const string& contact) {
+            const string& auth_user,
+            const string& user,
+            const string& pass,
+            const string& realm,
+            const string& contact) {
+
+  string auth_user_temp = auth_user.empty() ? user : auth_user;
 
-  string auth_user = user;
   string _user = user;
   if (username_with_domain && user.find('@')!=string::npos) {
     _user = user.substr(0, user.find('@'));
@@ -409,12 +414,15 @@ void DBRegAgent::createRegistration(long
   string handle = AmSession::getNewId();
   SIPRegistrationInfo reg_info(realm, _user,
 			       _user, // name
-			       auth_user,
+			       auth_user_temp, // auth_user
 			       pass,
 			       outbound_proxy, // proxy
 			       contact_uri // contact
 			       );
 
+DBG(" >>> realm '%s' - user '%s' - auth_user '%s' - pass: '%s' outbound_proxy '%s' contact_uri '%s'\n",
+      realm.c_str(), _user.c_str(), auth_user.c_str(), pass.c_str(), outbound_proxy.c_str(), contact_uri.c_str());
+
   registrations_mut.lock();
   try {
     if (registrations.find(subscriber_id) != registrations.end()) {
@@ -471,12 +479,14 @@ void DBRegAgent::createRegistration(long
 }
 
 void DBRegAgent::updateRegistration(long subscriber_id,
+				    const string& auth_user,
 				    const string& user,
 				    const string& pass,
 				    const string& realm,
 				    const string& contact) {
 
-  string auth_user = user;
+  string auth_user_temp = auth_user.empty() ? user : auth_user;
+
   string _user = user;
   if (username_with_domain && user.find('@')!=string::npos) {
     _user = user.substr(0, user.find('@'));
@@ -488,12 +498,13 @@ void DBRegAgent::updateRegistration(long
     registrations_mut.unlock();
     WARN("updateRegistration - registration %ld %s@%s unknown, creating\n",
 	 subscriber_id, _user.c_str(), realm.c_str());
-    createRegistration(subscriber_id, _user, pass, realm, contact);
+    createRegistration(subscriber_id, auth_user_temp, _user, pass, realm, contact);
     scheduleRegistration(subscriber_id);
     return;
   }
 
   bool need_reregister = it->second->getInfo().domain != realm
+    || it->second->getInfo().auth_user != auth_user_temp
     || it->second->getInfo().user != _user
     || it->second->getInfo().pwd  != pass
     || it->second->getInfo().contact != contact;
@@ -502,7 +513,7 @@ void DBRegAgent::updateRegistration(long
   string old_user = it->second->getInfo().user;
   it->second->setRegistrationInfo(SIPRegistrationInfo(realm, _user,
 						      _user, // name
-						      auth_user,
+						      auth_user_temp, // auth_user
 						      pass,
 						      outbound_proxy,   // proxy
 						      contact)); // contact
@@ -1097,26 +1108,32 @@ void DBRegAgent::timer_cb(RegTimer* time
 }
 
 
-void DBRegAgent::DIcreateRegistration(int subscriber_id, const string& user, 
+void DBRegAgent::DIcreateRegistration(int subscriber_id, const string& user,
 				      const string& pass, const string& realm,
-				      const string& contact,
+				      const string& contact, const string& auth_user,
 				      AmArg& ret) {
-  DBG("DI method: createRegistration(%i, %s, %s, %s, %s)\n",
-      subscriber_id, user.c_str(),
+
+  string auth_user_temp = auth_user.empty() ? user : auth_user;
+
+  DBG("DI method: createRegistration(%i, %s, %s, %s, %s, %s)\n",
+      subscriber_id, auth_user_temp.c_str(), user.c_str(),
       pass.c_str(), realm.c_str(), contact.c_str());
 
-  createRegistration(subscriber_id, user, pass, realm, contact);
+  createRegistration(subscriber_id, auth_user_temp, user, pass, realm, contact);
   scheduleRegistration(subscriber_id);
   ret.push(200);
   ret.push("OK");
 }
 
-void DBRegAgent::DIupdateRegistration(int subscriber_id, const string& user, 
+void DBRegAgent::DIupdateRegistration(int subscriber_id, const string& user,
 				      const string& pass, const string& realm,
-				      const string& contact,
+				      const string& contact, const string& auth_user,
 				      AmArg& ret) {
-  DBG("DI method: updateRegistration(%i, %s, %s, %s)\n",
-      subscriber_id, user.c_str(),
+
+  string auth_user_temp = auth_user.empty() ? user : auth_user;
+
+  DBG("DI method: updateRegistration(%i, %s, %s, %s, %s)\n",
+      subscriber_id, auth_user_temp.c_str(), user.c_str(),
       pass.c_str(), realm.c_str());
 
   string contact_uri = contact;
@@ -1124,7 +1141,7 @@ void DBRegAgent::DIupdateRegistration(in
     contact_uri = "sip:"+ user + "@" + contact_hostport;
   }
 
-  updateRegistration(subscriber_id, user, pass, realm, contact_uri);
+  updateRegistration(subscriber_id, auth_user_temp, user, pass, realm, contact_uri);
 
   ret.push(200);
   ret.push("OK");
@@ -1157,25 +1174,35 @@ void DBRegAgent::invoke(const string& me
 			const AmArg& args, AmArg& ret)
 {
   if (method == "createRegistration"){
-    args.assertArrayFmt("isss"); // subscriber_id, user, pass, realm
+    args.assertArrayFmt("issss"); // subscriber_id, user, pass, realm , auth_user
     string contact;
-    if (args.size() > 4) {
+    string auth_user;
+    if (args.size() == 5) {
       assertArgCStr(args.get(4));
       contact = args.get(4).asCStr();
+    } else if (args.size() > 5) {
+      assertArgCStr(args.get(4));
+      assertArgCStr(args.get(5));
+      contact = args.get(4).asCStr();
+      auth_user = args.get(5).asCStr();
     }
-    DIcreateRegistration(args.get(0).asInt(), args.get(1).asCStr(), 
-			 args.get(2).asCStr(),args.get(3).asCStr(),
-			 contact, ret);
+    DIcreateRegistration(args.get(0).asInt(), args.get(1).asCStr(),
+        args.get(2).asCStr(), args.get(3).asCStr(), contact, auth_user, ret);
   } else if (method == "updateRegistration"){
-    args.assertArrayFmt("isss"); // subscriber_id, user, pass, realm
+    args.assertArrayFmt("issss"); // subscriber_id, auth_user, user, pass, realm
     string contact;
-    if (args.size() > 4) {
+    string auth_user;
+    if (args.size() == 5) {
+      assertArgCStr(args.get(4));
+      contact = args.get(4).asCStr();
+    } else if (args.size() > 5) {
       assertArgCStr(args.get(4));
+      assertArgCStr(args.get(5));
       contact = args.get(4).asCStr();
+      auth_user = args.get(5).asCStr();
     }
     DIupdateRegistration(args.get(0).asInt(), args.get(1).asCStr(),
-			 args.get(2).asCStr(),args.get(3).asCStr(),
-			 contact, ret);
+			 args.get(2).asCStr(), args.get(3).asCStr(), contact, auth_user, ret);
   } else if (method == "removeRegistration"){
     args.assertArrayFmt("i"); // subscriber_id
     DIremoveRegistration(args.get(0).asInt(), ret);
--- a/apps/db_reg_agent/DBRegAgent.h
+++ b/apps/db_reg_agent/DBRegAgent.h
@@ -55,6 +55,7 @@ using std::queue;
 #define REG_STATUS_TO_BE_REMOVED_S "5"
 
 #define COLNAME_SUBSCRIBER_ID    "subscriber_id"
+#define COLNAME_AUTH_USER        "auth_user"
 #define COLNAME_USER             "user"
 #define COLNAME_PASS             "pass"
 #define COLNAME_REALM            "realm"
@@ -182,16 +183,18 @@ class DBRegAgent
 
   /** create registration in our list */
   void createRegistration(long subscriber_id,
-			  const string& user,
-			  const string& pass,
-			  const string& realm,
-			  const string& contact);
+        const string& auth_user,
+        const string& user,
+        const string& pass,
+        const string& realm,
+        const string& contact);
   /** update registration in our list */
   void updateRegistration(long subscriber_id,
-			  const string& user,
-			  const string& pass,
-			  const string& realm,
-			  const string& contact);
+        const string& auth_user,
+        const string& user,
+        const string& pass,
+        const string& realm,
+        const string& contact);
 
   /** remove registration */
   void removeRegistration(long subscriber_id);
@@ -245,12 +248,12 @@ class DBRegAgent
 
   AmDynInvoke* uac_auth_i;
 
-  void DIcreateRegistration(int subscriber_id, const string& user, 
-			    const string& pass, const string& realm,
-			    const string& contact, AmArg& ret);
+  void DIcreateRegistration(int subscriber_id, const string& user,
+          const string& pass, const string& realm,
+          const string& contact, const string& auth_user, AmArg& ret);
   void DIupdateRegistration(int subscriber_id, const string& user, 
-			    const string& pass, const string& realm,
-			    const string& contact, AmArg& ret);
+          const string& pass, const string& realm,
+          const string& contact, const string& auth_user, AmArg& ret);
   void DIremoveRegistration(int subscriber_id, AmArg& ret);
   void DIrefreshRegistration(int subscriber_id, AmArg& ret);
 
